A comprehensive Agentic RAG (Retrieval-Augmented Generation) system built with CrewAI that demonstrates multi-agent collaboration for business intelligence and document analysis.
- 🗄️ ChromaDB Integration: Document storage and retrieval with persistent vector database
- 🔍 Web Search Capabilities: Real-time web search using SerperDevTool
- 🤝 Multi-Agent System: Specialized agents for different tasks (RAG, Web Search, Code Execution)
- ⚡ Fast LLM Inference: Supports Groq and Gemini APIs for high-speed processing
- 📊 Business Intelligence: Automated analysis and visualization generation
- 🏗️ Hierarchical Process: Manager agent coordinates specialized workers
- 🔧 Flexible Configuration: Easy switching between LLM providers
📋 View Detailed Architecture Specification
Complete technical specification of the multi-agent architecture with ChromaDB integration, web scraping capabilities, and hierarchical task coordination for comprehensive business intelligence analysis.
- Python >=3.10, <=3.13
- UV for dependency management
-
Clone the repository:
git clone <your-repo-url> cd agentic-rag-practical-example
-
Install UV:
pip install uv
-
Install dependencies:
crewai install
-
Copy environment template:
cp .env.example .env
-
Add your API keys to
.env
:SERPER_API_KEY=your_serper_api_key_here GROQ_API_KEY=your_groq_api_key_here LLM=groq/llama3-70b-8192 OPENAI_API_KEY=your_groq_api_key_here # Used for CrewAI validation
-
Load documents into ChromaDB (optional):
python src/agentic_rag/load_chroma_docs.py
crewai run
This will:
- Analyze business documents using RAG
- Generate comprehensive business trends report
- Create visualization code for data insights
- Output results to
outputs/
directory
- 📚 Document RAG Agent: Retrieves information from ChromaDB vector database
- 🌐 Web Agent: Performs real-time web searches using SerperDevTool
- 💻 Code Execution Agent: Generates and executes analysis code
- 📋 Fetch Tax Docs: Retrieves relevant documents from internal database
- ❓ Answer Question: Provides detailed answers using RAG
- 📈 Business Trends: Analyzes trends and generates insights
- 📊 Graph Visualization: Creates data visualization code
- ChromaDBTool: Custom tool for vector database operations
- SerperDevTool: Web search capabilities
- ScrapeWebsiteTool: Website content scraping and analysis
agentic-rag-practical-example/
├── src/agentic_rag/
│ ├── config/
│ │ ├── agents.yaml # Agent configurations
│ │ └── tasks.yaml # Task definitions
│ ├── tools/
│ │ └── chromadb_tool.py # Custom ChromaDB tool
│ ├── crew.py # Main crew definition
│ ├── main.py # Entry point
│ └── load_chroma_docs.py # Document loader
├── internal_docs/ # Sample documents
├── db/ # ChromaDB storage
├── outputs/ # Generated reports
├── .env.example # Environment template
└── README.md
The system supports multiple LLM providers. Update your .env
file:
For Groq:
LLM=groq/llama3-70b-8192
GROQ_API_KEY=your_groq_api_key
OPENAI_API_KEY=your_groq_api_key
For Gemini:
LLM=gemini/gemini-1.5-pro
GEMINI_API_KEY=your_gemini_api_key
OPENAI_API_KEY=your_gemini_api_key
Edit src/agentic_rag/main.py
to change the analysis query:
inputs = {
"query": "Your custom business question here",
"company": "Your Company Name",
"company_description": "Brief company description",
}
The system generates:
-
Business Trends Report (
outputs/business_trends.md
)- Financial analysis over multiple years
- Revenue and expense trends
- Profitability insights
-
Visualization Code (
outputs/visualize.ipynb
)- Python matplotlib scripts
- Interactive data visualizations
- Chart generation code
- Create a new tool in
src/agentic_rag/tools/
- Import and add to agent configuration in
crew.py
- Update agent YAML configurations as needed
crewai train <n_iterations> <filename>
crewai test <n_iterations> <model_name>
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.