# Setup Guide This guide walks you through setting up the Zynd Protocols Application on your local machine. ## ๐Ÿ“‹ Prerequisites - **Python**: 3.10 or higher - **pip**: Latest version - **Git**: For cloning the repository - **API Keys**: - Groq API key (for LLM) - Google API key (for embeddings) - LangSmith API key (optional, for tracing) ## ๐Ÿš€ Installation ### Step 1: Clone the Repository ```bash git clone cd zynd-protocals-application ``` ### Step 2: Create Virtual Environment **Windows:** ```bash python -m venv venv venv\Scripts\activate ``` **Linux/Mac:** ```bash python3 -m venv venv source venv/bin/activate ``` ### Step 3: Install Dependencies ```bash pip install -r requirements.txt ``` **Dependencies include:** - `langchain` - LLM framework - `langgraph` - Multi-agent orchestration - `langchain-groq` - Groq LLM provider - `langchain-google-genai` - Google embeddings - `chromadb` - Vector database - `pydantic` - Data validation - `python-dotenv` - Environment management ### Step 4: Configure Environment Variables Create a `.env` file in the project root: ```bash # LLM Provider (Groq) GROQ_API_KEY=your_groq_api_key_here # Google (for embeddings) GOOGLE_API_KEY=your_google_api_key_here # LangSmith (Optional - for tracing/debugging) LANGCHAIN_TRACING_V2=true LANGCHAIN_ENDPOINT=https://api.smith.langchain.com LANGCHAIN_API_KEY=your_langsmith_api_key_here LANGCHAIN_PROJECT=zynd-protocols ``` **Get API Keys:** - **Groq**: [https://console.groq.com](https://console.groq.com) - **Google AI Studio**: [https://aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey) - **LangSmith**: [https://smith.langchain.com](https://smith.langchain.com) ### Step 5: Verify Configuration ```bash python check_env.py ``` This script checks if all required environment variables are set. ### Step 6: Prepare Vector Database The application uses ChromaDB for RAG. Ensure you have policy documents loaded: ```bash # If you have a chroma_db.zip file, extract it unzip chroma_db.zip # Otherwise, you'll need to populate the database with your documents # (See Development Guide for details) ``` ## ๐ŸŽฏ Running the Application ### Standard Mode ```bash python src/main.py ``` You'll see the interactive CLI: ``` ============================================= Civic Assistance Agent System (Zynd Enhanced) --------------------------------------------- Type 'exit' or 'quit' to stop. ============================================= User (Question): ``` ### Streamlit UI Mode (Alternative) ```bash streamlit run src/streamlit_app.py ``` Access the web interface at `http://localhost:8501` ## ๐Ÿงช Testing Run the test suite: ```bash # All tests pytest # Unit tests only pytest tests/unit/ # Integration tests only pytest tests/integration/ # With coverage pytest --cov=src tests/ ``` ## โš™๏ธ Configuration ### LLM Provider Configuration The default LLM is **Groq** (fast and cost-effective). To switch providers, edit [`src/agents.py`](file:///c:/Users/bhara/Desktop/Projects/zynd-protocals-application/src/agents.py): **Use Google Gemini:** ```python from langchain_google_genai import ChatGoogleGenerativeAI llm = ChatGoogleGenerativeAI( model="gemini-2.0-flash-exp", temperature=0, google_api_key=os.getenv("GOOGLE_API_KEY") ) ``` **Use Ollama (Local):** ```python from langchain_ollama import ChatOllama llm = ChatOllama( model="llama3.2:3b", temperature=0 ) ``` ### Logging Configuration Logs are stored in `logs/` directory. Configure log level in [`src/logger.py`](file:///c:/Users/bhara/Desktop/Projects/zynd-protocals-application/src/logger.py): ```python logging.basicConfig( level=logging.INFO, # Change to DEBUG for verbose logging ... ) ``` ### Cache Configuration LLM response caching is enabled by default via [`src/cache_helper.py`](file:///c:/Users/bhara/Desktop/Projects/zynd-protocals-application/src/cache_helper.py). To disable: ```python # In each agent file (policy_navigator.py, etc.) # Comment out cache checks: # cached_result = CacheHelper.get_llm_cache(cache_key) ``` ## ๐Ÿ” Troubleshooting ### Issue: Import Errors **Solution**: Ensure virtual environment is activated and dependencies are installed: ```bash pip install -r requirements.txt ``` ### Issue: API Rate Limits **Solution**: - Check API key quotas - Switch to a different LLM provider - Enable caching to reduce API calls ### Issue: ChromaDB Not Found **Solution**: Ensure `chroma_db/` directory exists: ```bash # Check if directory exists ls chroma_db/ # If missing, extract from backup unzip chroma_db.zip ``` ### Issue: Slow Performance **Solutions**: 1. Use Groq instead of Ollama (20x faster) 2. Enable caching 3. Reduce retrieval chunk size in `rag.py` 4. Use smaller LLM model ### Issue: LangSmith Tracing Errors **Solution**: LangSmith is optional. To disable, remove from `.env`: ```bash # Comment out or remove these lines # LANGCHAIN_TRACING_V2=true # LANGCHAIN_API_KEY=... ``` ## ๐Ÿ“ Project Structure ``` zynd-protocals-application/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ main.py # Entry point โ”‚ โ”œโ”€โ”€ graph.py # Main orchestrator โ”‚ โ”œโ”€โ”€ agents.py # Agent configurations โ”‚ โ”œโ”€โ”€ state.py # Main state definition โ”‚ โ”œโ”€โ”€ schemas.py # Pydantic schemas โ”‚ โ”œโ”€โ”€ policy_navigator.py # Policy agent โ”‚ โ”œโ”€โ”€ eligibility_verification.py # Eligibility agent โ”‚ โ”œโ”€โ”€ benefits_matching.py # Benefits agent โ”‚ โ”œโ”€โ”€ advocacy_agent.py # Advocacy agent โ”‚ โ”œโ”€โ”€ rag.py # RAG setup โ”‚ โ”œโ”€โ”€ rag_agent.py # Agentic RAG โ”‚ โ”œโ”€โ”€ tools.py # Shared tools โ”‚ โ”œโ”€โ”€ prompts.py # System prompts โ”‚ โ”œโ”€โ”€ config.py # Configuration โ”‚ โ”œโ”€โ”€ logger.py # Logging setup โ”‚ โ”œโ”€โ”€ cache_helper.py # LLM caching โ”‚ โ””โ”€โ”€ langsmith_config.py # Tracing setup โ”œโ”€โ”€ tests/ โ”‚ โ”œโ”€โ”€ unit/ # Unit tests โ”‚ โ””โ”€โ”€ integration/ # Integration tests โ”œโ”€โ”€ docs/ # Documentation โ”œโ”€โ”€ chroma_db/ # Vector database โ”œโ”€โ”€ logs/ # Application logs โ”œโ”€โ”€ .env # Environment variables โ”œโ”€โ”€ requirements.txt # Python dependencies โ””โ”€โ”€ README.md # Project README ``` ## ๐Ÿ”„ Updating To update dependencies: ```bash pip install --upgrade -r requirements.txt ``` To update vector database with new documents: ```bash # See Development Guide for document ingestion process python scripts/ingest_documents.py ``` ## ๐Ÿณ Docker Setup (Optional) *Coming soon: Docker and docker-compose configurations* ## โœ… Verification Checklist After setup, verify: - [ ] Python 3.10+ installed - [ ] Virtual environment activated - [ ] All dependencies installed - [ ] `.env` file configured with API keys - [ ] `check_env.py` passes - [ ] ChromaDB directory exists - [ ] Application runs without errors - [ ] Can interact via CLI - [ ] Tests pass --- Next: [Agents Reference](agents.md) to understand each agent's capabilities.