Skip to content

Repository files navigation

Document Router

A generic document-based AI router that passes entire documents to specialized agents without RAG chunking.

Key Concept

  • 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

Architecture

  • DocumentRouter: Core routing system that manages agents and documents
  • GeneralAgent: Routes general questions to appropriate document experts
  • DocumentExpertAgent: Specialized agents with full document context
  • Tool-based switching between agents using OpenAI function calling

Usage

# 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 expert

Installation

uv sync
uv run python main.py

Files

  • main.py: Original implementation (now generic)
  • generic_document_router.py: Reusable router framework
  • example_config.py: Configuration examples for different use cases

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages