cr-agent / docs /COMPLETE_SETUP.md
Sibi Krishnamoorthy
first commit
fd06b5a
# πŸš€ Multi-Agent AI Backend - Complete Setup
## βœ… What's Working
### Backend (FastAPI + LangGraph)
- βœ… Weather Agent - Gets current weather and forecasts
- βœ… Document Agent - RAG with ChromaDB vector store (deterministic tool execution)
- ⚠️ Meeting Agent - Scheduling with weather checks (needs final fix)
- βœ… SQL Agent - Natural language to SQL queries
- βœ… File Upload - PDF/TXT/MD/DOCX processing
### Frontend (React.js)
- βœ… Modern gradient UI design
- βœ… Real-time chat with typing indicators
- βœ… File upload with drag-and-drop
- βœ… Chat memory (full conversation history)
- βœ… Example query buttons
- βœ… Error handling
## 🎯 Quick Start
### 1. Backend Setup
```powershell
# Ensure virtual environment
cd D:\python_workspace\multi-agent
# Start backend server
uv run uvicorn main:app --reload
```
Backend runs at: http://localhost:8000
API Docs: http://localhost:8000/docs
### 2. Frontend Setup
```powershell
# Open new terminal
cd D:\python_workspace\multi-agent\frontend
# First time only - install dependencies
npm install
# Start React development server
npm start
```
Frontend opens at: http://localhost:3000
## πŸ“ Usage Examples
### Via Frontend UI
1. Open http://localhost:3000
2. Click example buttons or type queries:
- "What's the weather in Chennai?"
- "Schedule team meeting tomorrow at 2pm"
- "Show all meetings scheduled tomorrow"
3. Upload documents via πŸ“ button
4. Ask questions about uploaded files
### Via API (cURL)
**Chat:**
```bash
curl -X POST http://localhost:8000/chat \
-H "Content-Type: application/json" \
-d '{"query": "What is the weather in Chennai?"}'
```
**Upload File:**
```bash
curl -X POST http://localhost:8000/upload \
-F "file=@document.pdf"
```
## πŸ—οΈ Architecture
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ React Frontend (Port 3000) β”‚
β”‚ β€’ Chat UI with memory β”‚
β”‚ β€’ File upload β”‚
β”‚ β€’ Example queries β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ HTTP (CORS enabled)
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FastAPI Backend (Port 8000) β”‚
β”‚ β€’ /chat endpoint β”‚
β”‚ β€’ /upload endpoint β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LangGraph Workflow β”‚
β”‚ (Router + 4 Agents) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β–Ό β–Ό β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Weather β”‚ β”‚ Document β”‚ β”‚ Meeting β”‚ β”‚ SQL β”‚
β”‚ Agent β”‚ β”‚ +RAG β”‚ β”‚ Agent β”‚ β”‚ Agent β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚ β”‚
β–Ό β–Ό β–Ό β–Ό
OpenWeather ChromaDB Schedule+ SQLite
API Vector DB Weather DB
```
## πŸ”§ Configuration
### Environment Variables (.env)
```bash
# Recommended for testing
GITHUB_TOKEN=ghp_your_token_here
# Alternative LLM providers
OPENAI_API_KEY=sk-proj-...
GOOGLE_API_KEY=AIza...
# Weather API
OPENWEATHERMAP_API_KEY=your_key
# Local Ollama (optional)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5:7b
```
### Get API Keys
- **GitHub Token**: https://github.com/settings/tokens (free, recommended)
- **OpenAI**: https://platform.openai.com/api-keys ($0.15/1M tokens)
- **OpenWeatherMap**: https://openweathermap.org/api (free tier)
## πŸ“Š Test Results
```
βœ… Weather Agent: Working perfectly
⚠️ Meeting Agent: Needs weather tool fix
βœ… SQL Agent: Working perfectly
βœ… Document RAG: Working with deterministic execution
β€’ PDF ingestion: ~2-5 seconds
β€’ Similarity scores: 0.59-0.70
β€’ Correct answers from documents
β€’ Web fallback for low confidence (< 0.7)
```
## πŸ› Troubleshooting
### Backend Issues
**"Port 8000 already in use"**
```powershell
# Kill existing process
npx kill-port 8000
# Or use different port
uvicorn main:app --port 8001
```
**"Database locked"**
```powershell
# Delete and recreate
rm meeting_database.db
uv run uvicorn main:app --reload
```
### Frontend Issues
**"npm install fails"**
```powershell
cd frontend
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
```
**"Cannot connect to backend"**
1. Check backend is running: http://localhost:8000/docs
2. Verify CORS is enabled in main.py
3. Check proxy in frontend/package.json
**"Port 3000 already in use"**
```powershell
npx kill-port 3000
# Or use different port
set PORT=3001 && npm start
```
## πŸ“ Project Structure
```
multi-agent/
β”œβ”€β”€ agents.py # LangGraph workflow
β”œβ”€β”€ tools.py # Tool implementations
β”œβ”€β”€ main.py # FastAPI server
β”œβ”€β”€ database.py # SQLite setup
β”œβ”€β”€ vector_store.py # ChromaDB manager
β”œβ”€β”€ models.py # Pydantic models
β”œβ”€β”€ test_agents.py # Test suite
β”œβ”€β”€ .env # Configuration
β”œβ”€β”€ pyproject.toml # Python dependencies
β”œβ”€β”€ FRONTEND_SETUP.md # Frontend guide
└── frontend/ # React app
β”œβ”€β”€ public/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ App.js # Main component
β”‚ β”œβ”€β”€ App.css # Styling
β”‚ └── index.js # Entry point
β”œβ”€β”€ package.json # NPM dependencies
└── README.md
```
## πŸš€ Production Deployment
### Backend (FastAPI)
```powershell
# Install production server
uv add gunicorn
# Run with gunicorn
gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
```
### Frontend (React)
```powershell
cd frontend
# Build for production
npm run build
# Serve with any static server
npx serve -s build -p 3000
```
### Docker Deployment
```dockerfile
# Coming soon - Docker Compose setup
```
## πŸ“š Documentation
- [Frontend Setup Guide](FRONTEND_SETUP.md)
- [Tool Calling Issue Analysis](TOOL_CALLING_ISSUE.md)
- [GitHub Models Setup](GITHUB_MODELS_SETUP.md)
- [Quick Start Guide](QUICK_START.md)
## πŸŽ‰ Features Completed
βœ… **Backend:**
- Multi-agent orchestration with LangGraph
- Vector store RAG with ChromaDB
- Deterministic tool execution
- File upload and processing
- Weather integration
- SQL database queries
- Lightweight Docling config (no vision models)
βœ… **Frontend:**
- Modern gradient UI
- Real-time chat
- File upload interface
- Chat memory
- Example queries
- Typing indicators
- Error handling
- Mobile responsive
## πŸ”œ Next Steps
1. **Fix Meeting Agent** - Apply deterministic weather tool execution
2. **Add DuckDuckGo Search** - Install package for web fallback
3. **Enhance UI** - Add more features to frontend
4. **Deploy** - Production deployment guide
## πŸ’‘ Tips
- **Use GitHub Models** for stable testing (free tier)
- **Upload test documents** to see RAG in action
- **Check similarity scores** in backend logs
- **Clear chat** to start fresh conversations
- **Use example queries** for quick testing
---
**Made with ❀️ using FastAPI, LangGraph, React, and ChromaDB**