Metadata-Version: 2.4
Name: master-assistant-query-routing
Version: 0.2.0
Summary: Corpus-coupled, drift-free routing for multi-collection RAG.
Project-URL: Homepage, https://github.com/umangchaudhari/master-assistant-query-routing
Project-URL: Repository, https://github.com/umangchaudhari/master-assistant-query-routing
Project-URL: Issues, https://github.com/umangchaudhari/master-assistant-query-routing/issues
Project-URL: Changelog, https://github.com/umangchaudhari/master-assistant-query-routing/blob/main/CHANGELOG.md
Author: Umang Chaudhari
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: llm,multi-agent,rag,routing,vector-search
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: all
Requires-Dist: anthropic>=0.40; extra == 'all'
Requires-Dist: google-genai>=1.66.0; extra == 'all'
Requires-Dist: ollama>=0.4; extra == 'all'
Requires-Dist: openai>=1.0; extra == 'all'
Requires-Dist: qdrant-client>=1.17.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.40; extra == 'anthropic'
Provides-Extra: gemini
Requires-Dist: google-genai>=1.66.0; extra == 'gemini'
Provides-Extra: ollama
Requires-Dist: ollama>=0.4; extra == 'ollama'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Provides-Extra: qdrant
Requires-Dist: qdrant-client>=1.17.0; extra == 'qdrant'
Description-Content-Type: text/markdown

# Master Assistant Query Routing (MAA)

Drift-free query routing for multi-collection RAG via parallel corpus probing.

Given a natural-language query, MAA decides **which document collection(s) it
belongs to** — by probing every configured vector-store collection in parallel,
scoring each from the actual retrieved chunks, and asking a routing LLM to read
those chunks and return a structured JSON decision. The routing signal is the
**live corpus itself**, so re-indexing your data updates routing automatically —
there is no description or utterance list to keep in sync.

**Paper:** https://doi.org/10.5281/zenodo.20348330

## Install

```bash
# everything — all providers (Gemini, OpenAI, Anthropic, Ollama) + Qdrant
pip install "master-assistant-query-routing[all]"

# or install only what you need
pip install "master-assistant-query-routing[openai,qdrant]"
```

## Usage

```python
import asyncio
from maa import route_query, Config
from maa.providers.openai import OpenAIEmbedder, OpenAIRoutingLLM
from maa.stores.qdrant import QdrantVectorStore

async def main():
    embedder = OpenAIEmbedder(api_key="sk-...", model="text-embedding-3-large")
    llm      = OpenAIRoutingLLM(api_key="sk-...", model="gpt-5.4-mini")
    store    = QdrantVectorStore(host="localhost", port=6333)

    cfg = Config(collections=["billing", "technical", "accounts"])

    result = await route_query(
        "why was I charged twice this month",
        cfg, embedder=embedder, llm=llm, store=store,
    )
    print(result["collections"])   # e.g. ['billing']

asyncio.run(main())
```

Returns a dict with `collections` (the routing decision), `analysis`
(per-collection confidence + evidence), and `reasoning`. Pass `verbose=True` to
also include the raw probe scores and retrieved chunks.

## License

Apache-2.0.
