# ๐Ÿš€ Quick Start Guide - Agentic AI Backend ## Prerequisites ## Step 1: Verify Installation โœ… Dependencies are already installed. Verify with: ```powershell python -c "import chromadb, sentence_transformers; print('โœ… Vector Store packages installed')" ``` ## Step 2: Configure Environment ๐Ÿ”ง ### Option 1: GitHub Models (Recommended) โญ **Free, fast, and reliable!** 1. **Get a GitHub token:** https://github.com/settings/tokens 2. **Edit `.env`:** ```powershell Copy-Item .env.template .env notepad .env ``` 3. **Add your tokens:** ```bash GITHUB_TOKEN=ghp_your_github_token_here OPENWEATHERMAP_API_KEY=your_weather_api_key_here ``` **See detailed setup:** [GITHUB_MODELS_SETUP.md](GITHUB_MODELS_SETUP.md) ### Option 2: Local with Ollama If you prefer running locally: 1. **Install a capable Ollama model:** ```powershell ollama pull llama3.2 # Better than qwen3:0.6b ``` 2. **Configure `.env`:** ```bash OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=llama3.2 OPENWEATHERMAP_API_KEY=your_weather_api_key_here ``` **Note:** GitHub Models recommended for better reliability and tool calling. ## Step 3: Initialize Database ๐Ÿ’พ ```powershell python seed_data.py ``` This creates: Expected output: ``` Database initialized Sample meetings created successfully ``` ## Step 4: Run Tests ๐Ÿงช ```powershell python test_agents.py ``` This runs 6 comprehensive tests: 1. โœ… Weather Agent - Current weather 2. โœ… Meeting Agent - Weather-conditional scheduling 3. โœ… SQL Agent - Database queries 4. โœ… Document RAG - High confidence retrieval 5. โœ… Web Fallback - Low confidence web search 6. โœ… Specific Retrieval - Precise information extraction **First run will download the embedding model (~80MB) - this is normal!** ## Step 5: Start the API Server ๐ŸŒ ```powershell python main.py ``` Server starts at: **http://127.0.0.1:8000** API docs available at: **http://127.0.0.1:8000/docs** ## Step 6: Test API Endpoints ๐Ÿ“ก ### Test 1: Weather Query ```powershell $body = @{ query = "What's the weather in Paris today?" } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8000/chat" ` -ContentType "application/json" -Body $body ``` ### Test 2: Upload Document ```powershell $filePath = "C:\path\to\your\document.pdf" curl -X POST "http://127.0.0.1:8000/upload" -F "file=@$filePath" ``` Response will include `file_path` - use it in the next request. ### Test 3: RAG Query ```powershell $body = @{ query = "What does the document say about remote work?" file_path = "D:\python_workspace\multi-agent\uploads\uuid.pdf" } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8000/chat" ` -ContentType "application/json" -Body $body ``` ### Test 4: Meeting Scheduling ```powershell $body = @{ query = "Schedule a team meeting tomorrow at 3 PM in London if weather is good. Include Alice and Bob." } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8000/chat" ` -ContentType "application/json" -Body $body ``` ### Test 5: SQL Query ```powershell $body = @{ query = "Show me all meetings scheduled for this week" } | ConvertTo-Json Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:8000/chat" ` -ContentType "application/json" -Body $body ``` ## Expected Behavior ๐ŸŽฏ ### Weather Agent ### Document RAG Agent ### Meeting Agent ### SQL Agent ## Troubleshooting ๐Ÿ”ง ### Issue: "No valid LLM configured" **Solution:** Ensure Ollama is running at http://localhost:11434 ```powershell # Check if Ollama is running Invoke-WebRequest http://localhost:11434 ``` ### Issue: "Weather API key not configured" **Solution:** Add your API key to `.env`: ```bash OPENWEATHERMAP_API_KEY=your_key_here ``` ### Issue: "Document ingestion failed" **Solution:** Check file format (PDF/TXT/MD/DOCX) and size (<10MB) ### Issue: Slow first RAG query **Expected:** First run downloads sentence-transformers model (~80MB) Subsequent queries will be fast. ### Issue: Import errors in IDE **Normal:** VSCode may show import warnings until packages are fully indexed. Code will run fine. ## Understanding the RAG Workflow ๐Ÿ“š ``` User uploads document.pdf โ†“ 1. Parse with Docling โ†“ 2. Chunk into 500-char pieces (50-char overlap) โ†“ 3. Generate embeddings with sentence-transformers โ†“ 4. Store in ChromaDB (./chroma_db/) โ†“ User asks: "What is the policy?" โ†“ 5. Search vector store for similar chunks โ†“ 6. Check similarity score โ†“ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Score โ‰ฅ 0.7 โ”‚ Score < 0.7 โ”‚ โ”‚ (confident) โ”‚ (uncertain) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ†“ โ†“ Return doc Search web answer + combine results ``` ## File Structure ๐Ÿ“ ``` multi-agent/ โ”œโ”€โ”€ main.py # FastAPI server โ”œโ”€โ”€ agents.py # LangGraph agents โ”œโ”€โ”€ tools.py # Agent tools โ”œโ”€โ”€ vector_store.py # ChromaDB manager (NEW) โ”œโ”€โ”€ database.py # SQLite config โ”œโ”€โ”€ models.py # SQLAlchemy models โ”œโ”€โ”€ test_agents.py # Test suite โ”œโ”€โ”€ seed_data.py # DB initialization โ”œโ”€โ”€ .env # Your configuration โ”œโ”€โ”€ .env.template # Configuration template โ”œโ”€โ”€ database.db # SQLite database โ”œโ”€โ”€ chroma_db/ # Vector store (auto-created) โ”œโ”€โ”€ uploads/ # Uploaded documents โ””โ”€โ”€ IMPLEMENTATION_COMPLETE.md # Full documentation ``` ## Next Steps ๐ŸŽฏ 1. **Explore the API:** Visit http://127.0.0.1:8000/docs 2. **Try different queries:** Test edge cases and complex scenarios 3. **Upload your documents:** Try PDFs, policies, resumes 4. **Check vector store:** Inspect `./chroma_db/` directory 5. **Review logs:** Monitor agent decisions and tool calls ## Performance Tips โšก ## Support ๐Ÿ“ž **You're all set! ๐ŸŽ‰ Start making requests to your AI backend!**