A generic document-based AI router that passes entire documents to specialized agents without RAG chunking.
- Full Document Context: Load complete PDF/document content into agent prompts (no vector databases or chunking)
- Tool-Based Routing: Agents use function calls to switch between each other based on question type
- Specialized Expertise: Each agent has access to specific documents for deep technical understanding
- Structured Outputs: Pydantic validation for clean agent switching and tool calls
DocumentRouter: Core routing system that manages agents and documentsGeneralAgent: Routes general questions to appropriate document expertsDocumentExpertAgent: Specialized agents with full document context- Tool-based switching between agents using OpenAI function calling
# Basic setup
client = AzureOpenAI(endpoint="...", api_key="...", api_version="...")
router = create_document_chatbot(client, config)
# Interactive chat
router.chat("How does the authentication work?") # Routes to appropriate expertuv sync
uv run python main.pymain.py: Original implementation (now generic)generic_document_router.py: Reusable router frameworkexample_config.py: Configuration examples for different use cases