A sophisticated chatbot implementation that uses multiple specialized agents to process queries through different search and processing methods, powered by Azure OpenAI, Azure AI Search, and Azure SQL Database.
- Query decomposition for complex questions
- Intelligent intent routing between different search methods
- Multiple search capabilities:
- Keyword-based search using Azure AI Search
- Semantic search using FAISS vector store
- SQL database queries
- Direct LLM processing
- Answer generation combining multiple data sources
- Web interface for easy interaction
-
Python 3.8+
-
Azure OpenAI API accessgit config --global user.name "Your GitHub Username" git config --global user.email "[email protected]"
-
Azure AI Search instance
-
Azure SQL Database
-
FAISS index for vector search
- Clone the repository:
git clone <repository-url>
cd multi-agent-chatbot-langgraph
Copy
Insert at cursor
markdown
Install required packages:
pip install pyodbc flask python-dotenv langgraph langchain openai faiss-cpu
Copy
Insert at cursor
bash
Create a .env file in the project root with the following variables:
AZURE_OPENAI_DEPLOYMENT_NAME=<your-deployment-name>
AZURE_OPENAI_API_BASE=<your-api-base>
AZURE_OPENAI_API_KEY=<your-api-key>
AZURE_SEARCH_INDEX_NAME=<your-index-name>
AZURE_SEARCH_SERVICE_NAME=<your-service-name>
AZURE_SEARCH_API_KEY=<your-search-api-key>
AZURE_SQL_SERVER=<your-sql-server>
AZURE_SQL_DATABASE=<your-database>
AZURE_SQL_USERNAME=<your-username>
AZURE_SQL_PASSWORD=<your-password>
FAISS_INDEX_PATH=<path-to-faiss-index>
Copy
Insert at cursor
env
Project Structure
├── app.py # Main application file
├── templates/
│ └── index.html # Web interface template
├── .env # Environment variables
└── README.md # Project documentation
Copy
Insert at cursor
text
How It Works
Query Decomposition : Breaks down complex queries into simpler sub-queries
Intent Router : Determines the most appropriate search method
Search Agents :
Index Search: Uses Azure AI Search for keyword-based search
Vector Search: Uses FAISS for semantic similarity search
SQL Query: Executes database queries
LLM Processing: Direct language model processing
Answer Generation : Combines and refines results from different sources
Usage
Start the Flask application:
python app.py
Copy
Insert at cursor
bash
Open a web browser and navigate to http://localhost:5000
Enter your query in the text input and click "Submit"
Architecture
The application uses LangGraph to orchestrate multiple agents:
Query Decomposition Agent
Intent Router Agent
Index Search Agent
Vector Search Agent
SQL Query Agent
Answer Generation Agent
Each agent specializes in a specific task and communicates through the graph structure.
Security Notes
All sensitive credentials are stored in environment variables
Database connections are properly managed and closed
API keys and connection strings should be kept secure
Web interface uses proper input sanitization
Contributing
Fork the repository
Create a feature branch
Commit your changes
Push to the branch
Create a Pull Request
License
Add your chosen license here
This README provides a comprehensive overview of your project, including:
- What the project does
- How to set it up
- Required dependencies
- Configuration instructions
- Project structure
- How the system works
- Usage instructions
- Security considerations
- Contributing guidelines
You should customize this template by:
1. Adding the actual repository URL
2. Choosing and adding an appropriate license
3. Adding any specific deployment instructions for your environment
4. Updating any specific requirements or configurations unique to your implementation
Would you like me to explain or modify