An intelligent multi-agent AI system that automatically classifies and routes queries to specialized agents
Features • Installation • Usage • Architecture • Demo
AgentX is a sophisticated multi-agent AI system that intelligently routes user queries to the most appropriate specialized agent. Built with LangChain and powered by LLaMA 3.1, it seamlessly handles diverse query types through three specialized agents:
- General Knowledge Agent - Handles open-domain questions
- RAG Agent - Searches internal project documents using vector similarity
- SQL Agent - Converts natural language to SQL queries
- Intelligent Query Classification - Automatically determines the best agent for each query
- Retrieval-Augmented Generation (RAG) - Semantic search through project documents using FAISS
- Natural Language to SQL - Converts user questions to executable database queries
- Multi-Agent Orchestration - Seamless coordination between specialized AI components
- Robust Error Handling - JSON parsing and validation for reliable LLM responses
- Real-time Processing - Fast query routing and response generation
| Category | Technologies |
|---|---|
| Language | Python 3.11+ |
| AI/ML Framework | LangChain, Ollama |
| Language Model | LLaMA 3.1 (8B-instruct) |
| Vector Database | FAISS |
| Embeddings | HuggingFace Sentence Transformers |
| Database | SQLite3 |
| Data Processing | Pandas, NumPy |
- macOS (Intel or Apple Silicon)
- Python 3.11+
- Ollama installed and running
- 8GB+ RAM (recommended for LLaMA 3.1 8B model)
git clone https://github.com/yourusername/agentx.git
cd agentxchmod +x setup_agentx.sh
./setup_agentx.sh# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start Ollama and download model
ollama serve &
ollama pull llama3.1:8b-instruct-q8_0source venv/bin/activate
python agentx_original.pygraph TB
A[User Query] --> B[Decision Agent]
B --> C{Query Classification}
C -->|Type 1| D[General Agent]
C -->|Type 2| E[RAG Agent]
C -->|Type 3| F[SQL Agent]
E --> G[FAISS Vector DB]
E --> H[Project Documents]
F --> I[SQLite Database]
F --> J[Employee Records]
D --> K[Response]
E --> K
F --> K
- Classifies incoming queries using LLaMA 3.1
- Routes to appropriate specialized agent
- Returns structured JSON with reasoning
- Handles open-domain questions
- Uses LLM's built-in knowledge
- No external data sources required
- Searches project document database
- Uses FAISS for vector similarity search
- Provides context-aware responses
- Converts natural language to SQL
- Executes queries on employee database
- Returns formatted results
| Query Type | Example | Agent Used |
|---|---|---|
| General | "Why is global warming on the rise?" | General Agent |
| Project | "What projects involve robotics?" | RAG Agent |
| Employee | "Who has 3+ years of experience?" | SQL Agent |
agentx/
├── agentx_original.py # Main application
├── input/
│ └── Projects.txt # Project documents
├── setup_agentx.sh # Setup script
├── requirements.txt # Dependencies
└── README.md # This file
# Model configuration
MODEL_NAME=llama3.1:8b-instruct-q8_0
TEMPERATURE=0
MAX_TOKENS=2048- Projects: Add to
input/Projects.txtseparated by########## - Employee Data: Modify the
employeeslist in the script - Embeddings: Customize the HuggingFace model in the code
Processing Query: Have we undertaken any projects related to robotics?
Query Type: 2
Reasoning: This query pertains to a specific project...
Searching Company's Internal Project Database
Response: Yes, we have undertaken Project Gamma - Autonomous Robotics Platform...- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Meta AI for the LLaMA model
- LangChain for the excellent framework
- HuggingFace for sentence transformers
- Facebook Research for FAISS