A sophisticated multi-agent system designed to answer questions by leveraging internal knowledge bases, external search, and document summarization - all orchestrated through a modern web interface.
- π€ Specialized Agents: Dedicated agents for knowledge retrieval and summarization, each optimized for their specific tasks
- π― Intelligent Routing: A central router analyzes incoming queries and directs them to the most suitable agent or processing path
- π Knowledge-First Approach: Prioritizes searching internal document base before resorting to external searches, providing properly sourced responses
- π External Search Integration: Seamlessly transitions to web search when internal knowledge is insufficient, with proper citation of sources
- π Efficient Summarization: Processes and condenses large documents using a map-reduce approach with LLM-powered chunking
- π Advanced Orchestration: Utilizes LangGraph for robust, graph-based agent coordination and conversation flow control
- π§ Contextual Conversations: Maintains conversation history and context, with automatic summarization for longer interactions
- π» Modern Web Interface: Clean, responsive UI with gradient design for interacting with the multi-agent system
- Python >= 3.11
- OpenAI API Key (Required)
- Tavily API Key (Required)
- LangSmith API Key (Optional - for tracing/debugging)
- Clone the repository:
git clone https://github.com/DevXSoni021/Multi_agent_langGraph_System.git
cd Multi_agent_langGraph_System- Install dependencies using
uv(recommended):
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate
uv pip install -e .
uv pip install "langgraph-cli[inmem]"- Set up environment variables:
# Create .env file in src/backend/
cp src/backend/.env.example src/backend/.env
# Edit .env with your API keys- Run the application:
langgraph dev --no-browserThe application will be available at http://127.0.0.1:2024
Create a .env file in src/backend/ with:
OPENAI_API_KEY=your_openai_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
LANGCHAIN_API_KEY=your_langchain_api_key_here # OptionalNote: LangSmith API key is OPTIONAL. The system works perfectly without it. LangSmith is only needed for tracing, debugging, and monitoring. See LANGSMITH_INFO.md for details.
multi_agent_system/
β
βββ src/
β βββ backend/ # Backend server and agent logic
β β βββ agents/ # Agent implementations
β β β βββ knowledge/ # Knowledge retrieval agent
β β β β βββ __init__.py
β β β β βββ graph.py # Knowledge agent workflow graph
β β β β βββ prompts.py # LLM prompts for knowledge agent
β β β β βββ schemas.py # State schemas for knowledge agent
β β β β βββ tools.py # RAG and Tavily search tools
β β β βββ orchestrator/ # Central router logic
β β β β βββ __init__.py
β β β β βββ graph.py # Main orchestrator graph
β β β β βββ prompts.py # Router and answer prompts
β β β β βββ schemas.py # Agent state schemas
β β β βββ summarizer/ # Document summarization agent
β β β βββ __init__.py
β β β βββ graph.py # Summarizer workflow graph
β β β βββ prompts.py # Summarization prompts
β β β βββ schemas.py # Summarizer state schemas
β β β βββ tools.py # Document chunking tools
β β βββ utils/ # Shared utilities
β β β βββ __init__.py
β β β βββ document_ingestion.py # Document upload and ingestion
β β β βββ file_utils.py # File processing utilities
β β β βββ message_utils.py # Message formatting utilities
β β βββ app.py # FastAPI application
β β βββ config.py # Configuration management
β β βββ routes.py # API endpoints
β β βββ schemas.py # Pydantic models for API
β β βββ exceptions.py # Custom exception classes
β β βββ .env.example # Environment variables template
β β
β βββ static/ # Frontend assets
β βββ index.html # Main HTML interface
β βββ js/
β β βββ config/
β β β βββ config.js # API configuration
β β βββ script.js # Frontend JavaScript logic
β βββ styles/
β βββ main.css # CSS styling
β
βββ screenshots/ # Application screenshots
β βββ 1-welcome-screen.png
β βββ 2-chat-interface-empty.png
β βββ 3-chat-with-conversation.png
β βββ 4-sidebar-with-conversations.png
β βββ 5-empty-new-chat.png
β βββ 6-knowledge-base-section.png
β
βββ examples/ # Example use cases
β βββ use_cases.md
β
βββ data/ # Data storage (created at runtime)
β βββ chroma_db/ # Vector database storage
β
βββ .github/ # GitHub configuration
β βββ workflows/ # GitHub Actions workflows
β
βββ API_KEY_FIX.md # API key troubleshooting guide
βββ LANGSMITH_INFO.md # LangSmith integration info
βββ REQUIRED_KEYS_SUMMARY.md # Quick API keys reference
βββ SETUP_REQUIREMENTS.md # Detailed setup guide
βββ README.md # This file
βββ LICENSE # MIT License
βββ langgraph.json # LangGraph configuration
βββ pyproject.toml # Python project configuration
βββ uv.lock # Dependency lock file
βββ .gitignore # Git ignore rules
graph TB
User[User] -->|HTTP Request| WebUI[Web Interface]
WebUI -->|API Calls| FastAPI[FastAPI Server]
FastAPI -->|Routes| Router[Orchestrator Router]
Router -->|Route Decision| KnowledgeAgent[Knowledge Agent]
Router -->|Route Decision| SummarizerAgent[Summarizer Agent]
Router -->|Route Decision| QuickAnswer[Quick Answer]
KnowledgeAgent -->|Search| VectorDB[(ChromaDB<br/>Vector Store)]
KnowledgeAgent -->|Fallback| Tavily[Tavily<br/>Web Search]
SummarizerAgent -->|Process| DocumentChunks[Document<br/>Chunking]
DocumentChunks -->|Parallel| LLM[OpenAI LLM]
LLM -->|Summarize| CombinedSummary[Combined<br/>Summary]
KnowledgeAgent -->|Results| Router
SummarizerAgent -->|Results| Router
QuickAnswer -->|Response| Router
Router -->|Final Answer| FastAPI
FastAPI -->|Response| WebUI
WebUI -->|Display| User
style Router fill:#667eea,stroke:#764ba2,color:#fff
style KnowledgeAgent fill:#4f46e5,stroke:#4338ca,color:#fff
style SummarizerAgent fill:#4f46e5,stroke:#4338ca,color:#fff
style VectorDB fill:#10b981,stroke:#059669,color:#fff
style Tavily fill:#f59e0b,stroke:#d97706,color:#fff
graph LR
Start([User Query]) --> Router{Orchestrator<br/>Router}
Router -->|Document<br/>Summarization| Summarizer[Summarizer Agent]
Router -->|Knowledge<br/>Query| Knowledge[Knowledge Agent]
Router -->|Simple<br/>Question| Answer[Quick Answer]
Knowledge --> RefineQuery[Refine Query]
RefineQuery --> Retrieve[Retrieve from<br/>Vector DB]
Retrieve --> CheckRelevant{Relevant?}
CheckRelevant -->|Yes| PrepareOutput[Prepare Output]
CheckRelevant -->|No| ExternalSearch[External<br/>Web Search]
ExternalSearch --> PrepareOutput
PrepareOutput --> Answer
Summarizer --> ProcessDoc[Process Document]
ProcessDoc --> ChunkDoc[Chunk Document]
ChunkDoc -->|Parallel| SummarizeChunks[Summarize<br/>Chunks]
SummarizeChunks --> Combine[Combine<br/>Summaries]
Combine --> Answer
Answer --> CheckHistory{Need<br/>Summarization?}
CheckHistory -->|Yes| SummarizeConv[Summarize<br/>Conversation]
CheckHistory -->|No| End([Response])
SummarizeConv --> End
style Router fill:#667eea,stroke:#764ba2,color:#fff
style Knowledge fill:#4f46e5,stroke:#4338ca,color:#fff
style Summarizer fill:#4f46e5,stroke:#4338ca,color:#fff
style Answer fill:#10b981,stroke:#059669,color:#fff
graph TD
Start([Query Input]) --> Refine[Refine Query<br/>with LLM]
Refine --> Retrieve[Retrieve Documents<br/>from Vector DB]
Retrieve --> Evaluate{Evaluate<br/>Relevance}
Evaluate -->|Relevant| FormatInternal[Format Internal<br/>Documents]
Evaluate -->|Not Relevant| SearchExternal[Search External<br/>Sources - Tavily]
SearchExternal --> FormatExternal[Format External<br/>Results]
FormatInternal --> Output[Prepare Knowledge<br/>Output]
FormatExternal --> Output
Output --> End([Return to<br/>Orchestrator])
style Refine fill:#667eea,stroke:#764ba2,color:#fff
style Retrieve fill:#4f46e5,stroke:#4338ca,color:#fff
style Evaluate fill:#f59e0b,stroke:#d97706,color:#fff
style SearchExternal fill:#ef4444,stroke:#dc2626,color:#fff
graph TD
Start([Document Input]) --> Analyze[Analyze Document<br/>Structure]
Analyze --> Chunk[Chunk Document<br/>Intelligently]
Chunk --> Distribute[Distribute Chunks<br/>for Parallel Processing]
Distribute -->|Chunk 1| Summarize1[Summarize Chunk 1]
Distribute -->|Chunk 2| Summarize2[Summarize Chunk 2]
Distribute -->|Chunk N| SummarizeN[Summarize Chunk N]
Summarize1 --> Combine[Combine All<br/>Summaries]
Summarize2 --> Combine
SummarizeN --> Combine
Combine --> End([Return Summary<br/>to Orchestrator])
style Analyze fill:#667eea,stroke:#764ba2,color:#fff
style Chunk fill:#4f46e5,stroke:#4338ca,color:#fff
style Distribute fill:#f59e0b,stroke:#d97706,color:#fff
style Combine fill:#10b981,stroke:#059669,color:#fff
sequenceDiagram
participant User
participant WebUI
participant FastAPI
participant Router
participant KnowledgeAgent
participant VectorDB
participant Tavily
participant SummarizerAgent
participant LLM
User->>WebUI: Send Message
WebUI->>FastAPI: POST /api/conversations/{thread_id}/send-message
FastAPI->>Router: Route Query
alt Knowledge Query
Router->>KnowledgeAgent: Process Query
KnowledgeAgent->>VectorDB: Search Internal Docs
alt Documents Found & Relevant
VectorDB-->>KnowledgeAgent: Return Documents
KnowledgeAgent-->>Router: Formatted Results
else Documents Not Relevant
KnowledgeAgent->>Tavily: External Web Search
Tavily-->>KnowledgeAgent: Search Results
KnowledgeAgent-->>Router: Formatted Results
end
else Document Summarization
Router->>SummarizerAgent: Process Document
SummarizerAgent->>LLM: Analyze & Chunk
LLM-->>SummarizerAgent: Chunk Recommendations
SummarizerAgent->>LLM: Summarize Chunks (Parallel)
LLM-->>SummarizerAgent: Chunk Summaries
SummarizerAgent-->>Router: Combined Summary
else Simple Question
Router->>LLM: Direct Answer
LLM-->>Router: Response
end
Router->>FastAPI: Final Answer
FastAPI->>WebUI: Stream Response (SSE)
WebUI->>User: Display Answer
Modern welcome screen with gradient UI, feature highlights, and conversation history
Clean new chat interface ready for conversation with helpful tips
AI assistant responding to user queries with detailed, well-formatted responses and source citations
Sidebar showing conversation history, knowledge base, and navigation options
Starting a fresh conversation session with empty chat interface
Document upload feature for adding .txt, .md, or .pdf files to the knowledge base
- Location:
src/backend/agents/orchestrator/graph.py - Purpose: Central decision-making node that routes queries to appropriate agents
- Key Functions:
route_message(): Analyzes query and determines routing pathanswer(): Generates final response using agent outputssummarize_conversation(): Manages conversation history
- Location:
src/backend/agents/knowledge/graph.py - Purpose: Retrieves information from internal knowledge base or external sources
- Key Functions:
refine_query(): Optimizes query for better retrievaldirect_retrieval(): Searches vector databasecheck_internal_docs(): Evaluates document relevanceexternal_search_node(): Falls back to Tavily web searchprepare_output(): Formats results for orchestrator
- Location:
src/backend/agents/summarizer/graph.py - Purpose: Processes and summarizes large documents
- Key Functions:
analyze_document_structure(): Determines optimal chunking strategyprocess_document_node(): Chunks document intelligentlysummarize_chunk(): Summarizes individual chunks (parallel)combine_summaries(): Combines all chunk summaries
- Purpose: Stores and retrieves document embeddings
- Location:
data/chroma_db/(created at runtime) - Integration: Used by Knowledge Agent for RAG (Retrieval Augmented Generation)
- Frontend:
src/static/ - Features:
- Real-time chat with SSE streaming
- Document upload for knowledge base
- Session management
- Conversation history
- Modern gradient UI design
| Endpoint | Method | Description |
|---|---|---|
/api/ |
GET | API status check |
/api/new-thread |
GET | Create new conversation thread |
/api/conversations-list |
GET | Get all conversations |
/api/conversations/{thread_id} |
GET | Get specific conversation |
/api/conversations/{thread_id}/send-message |
POST | Send message to thread |
/api/conversations/{thread_id}/stream-message |
GET | Stream response (SSE) |
/api/conversations/{thread_id} |
DELETE | Delete specific thread |
/api/conversations |
DELETE | Delete all threads |
/api/upload-document/ |
POST | Upload document to knowledge base |
- Setup Requirements - Detailed setup guide
- Required Keys Summary - API keys reference
- LangSmith Info - Information about optional LangSmith integration
- API Key Fix Guide - Troubleshooting API key issues
- Question Answering: Ask questions and get answers from your knowledge base or web search
- Document Summarization: Upload large documents and get concise summaries
- Research Assistant: Combine internal knowledge with external web search
- Knowledge Base Management: Build and maintain a searchable document repository
- Backend: FastAPI, Python 3.11+
- AI Framework: LangGraph, LangChain
- LLM: OpenAI GPT-4o
- Embeddings: OpenAI text-embedding-3-small
- Vector DB: ChromaDB
- Web Search: Tavily API
- Frontend: Vanilla JavaScript, HTML5, CSS3
- Package Management: uv
This project is licensed under the MIT License - see the LICENSE file for details.
DevXSoni021
Built with:
- LangGraph - Multi-agent orchestration
- LangChain - LLM framework
- FastAPI - Web framework
- ChromaDB - Vector database
- Tavily - Web search API
GitHub: https://github.com/DevXSoni021/Multi_agent_langGraph_System
β If you find this project useful, please consider giving it a star!