yujierachel/multi-agent-chatbot
๐ค Multi-Agent Knowledge Retrieval Chatbot
An AI-powered chatbot using OpenAI GPT-3.5 and Pinecone for intelligent knowledge retrieval. This chatbot efficiently handles user queries by orchestrating multiple AI agents, retrieving relevant documents, and generating context-aware responses.
Project Overview
In this project, I built a chatbot that:
- Retrieves relevant documents using Pinecone vector search
- Generates intelligent responses with OpenAI GPT-3.5
- Uses a multi-agent architecture to ensure modular and scalable processing
The system consists of multiple agents:
- Query Agent - Converts user queries into embeddings and retrieves relevant documents.
- Relevance Agent - Filters out unrelated search results.
- Answering Agent - Generates intelligent, context-aware responses using OpenAI LLM.
- Obnoxious Agent - Ensures safety by moderating inappropriate queries.
- Head Agent - Coordinates the workflow between all agents, ensuring efficiency.
Key Challenges & Solutions
1. Handling Irrelevant Questions
- If no relevant documents are found, the bot politely informs the user instead of generating misleading responses.
2. Filtering Inappropriate Queries
- The chatbot detects offensive or inappropriate queries and responds with a predefined safe message.
3. Managing General Conversations
- The chatbot handles general interactions, such as greetings, ensuring a user-friendly experience.
4. Multi-Turn Conversation Handling
- Users can ask follow-up questions, and the chatbot maintains context to provide deeper insights.
Project Architecture
โโโ agents.py # Implements the multi-agent system โโโ app.py # Streamlit-based UI for chatbot โโโ requirements.txt # Dependencies required for the project โโโ README.md # Project documentation โโโ .gitignore # Ensures sensitive files aren't committed
Installation & Setup
1. Clone the Repository
git clone https://github.com/YujieHan-Rachel/multi-agent-chatbot.git
cd multi-agent-chatbot2. Create virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
# Install required dependencies
pip install -r requirements.txt3. Set Up API Keys (Security Best Practice)
Ensure your OpenAI API Key and Pinecone API Key are stored as environment variables:
export OPENAI_API_KEY="your-openai-api-key"
export PINECONE_API_KEY="your-pinecone-api-key"(For Windows, use set instead of export.)
Run the Chatbot
streamlit run app.pyOpen your browser and go to http://localhost:8501 to interact with the chatbot.
Live Demo
๐ Hugging Face Space: [Insert Link Here] ๐ GitHub Repository: https://github.com/YujieHan-Rachel/multi-agent-chatbot
Customization & Enhancements
If you want to modify the chatbot behavior:
Optimize Retrieval: Modify QueryAgent in agents.py for better search results. Enhance Response Quality: Experiment with prompt engineering in AnsweringAgent. Improve Document Filtering: Adjust ranking logic in Relevance_Agent.
Contributing
Pull requests are welcome! If you find a bug or want to suggest improvements:
Fork the repo Create a new branch (git checkout -b feature-new-feature) Commit your changes (git commit -m "Added new feature") Push to your branch (git push origin feature-new-feature) Open a Pull Request
License
This project is licensed under the MIT License. Feel free to use and modify!
Contact
For questions or collaboration, reach out at:
Email: [yujierachel@gmail.com] LinkedIn: [LinkedIn Profile]
Final Notes
- This project showcases a scalable, modular AI chatbot with efficient knowledge retrieval.
- Ideal for AI-driven information retrieval, Q&A systems, and interactive chatbots.
- Can be expanded to support domain-specific datasets or company knowledge bases.
- Enjoy building AI-powered conversational systems! ๐
