{"id":47590100,"url":"https://github.com/scionoftech/agentic_rag","last_synced_at":"2026-04-01T17:15:16.789Z","repository":{"id":327881455,"uuid":"1111126495","full_name":"scionoftech/agentic_rag","owner":"scionoftech","description":" This repo shows how End to End Agentic RAG can be implemented using Multi Agent Orchestration using LangGraph etc.","archived":false,"fork":false,"pushed_at":"2025-12-06T10:26:14.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-10T04:22:27.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scionoftech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-06T10:23:05.000Z","updated_at":"2025-12-06T10:26:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/scionoftech/agentic_rag","commit_stats":null,"previous_names":["scionoftech/agentic_rag"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/scionoftech/agentic_rag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scionoftech%2Fagentic_rag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scionoftech%2Fagentic_rag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scionoftech%2Fagentic_rag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scionoftech%2Fagentic_rag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scionoftech","download_url":"https://codeload.github.com/scionoftech/agentic_rag/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scionoftech%2Fagentic_rag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-01T17:15:16.273Z","updated_at":"2026-04-01T17:15:16.779Z","avatar_url":"https://github.com/scionoftech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Agentic RAG Pipeline\n\nA production-ready **End-to-End Agentic RAG (Retrieval-Augmented Generation)** system built with **Multi-Agent Orchestration** using **LangGraph** and **durable execution** capabilities.\n\n## Overview\n\nThis project demonstrates a sophisticated RAG pipeline that uses multiple specialized AI agents working together to provide accurate, context-aware answers to user queries. The system leverages LangGraph for workflow orchestration with checkpointing support for durable execution.\n\n## Architecture\n\n### Multi-Agent System\n\nThe pipeline consists of four specialized agents:\n\n1. **Query Analyzer Agent**: Understands user intent, extracts entities, and reformulates queries for optimal retrieval\n2. **Retrieval Agent**: Fetches relevant documents from the vector store using similarity search with optional reranking\n3. **Synthesis Agent**: Generates comprehensive answers based on retrieved documents with proper citations\n4. **Evaluation Agent**: Validates answer quality, checks for hallucinations, and determines if regeneration is needed\n\n### Workflow\n\n```\nUser Query → Query Analyzer → Retrieval → Synthesis → Evaluation → Final Answer\n                                   ↑           ↑            ↓\n                                   └───────────┴────────────┘\n                                   (retry loop if needed)\n```\n\nThe LangGraph workflow supports:\n- **Durable Execution**: State persistence with SQLite checkpointing\n- **Retry Logic**: Automatic retry on failures with configurable max attempts\n- **Conditional Routing**: Smart decision-making between workflow steps\n- **State Management**: Complete tracking of all workflow states\n\n## Features\n\n- **Multi-Agent Orchestration**: Specialized agents for different tasks\n- **Durable Execution**: Fault-tolerant with state checkpointing\n- **Vector Store Integration**: ChromaDB for efficient similarity search\n- **Document Processing**: Support for PDF, TXT, DOCX, and more\n- **Quality Evaluation**: Built-in answer validation and scoring\n- **Interactive CLI**: Rich terminal interface for user interaction\n- **Batch Processing**: Handle multiple queries efficiently\n- **Health Monitoring**: System health checks and diagnostics\n- **Conversation Tracking**: Thread-based conversation management\n\n## Installation\n\n### Prerequisites\n\n- Python 3.9+\n- OpenAI API key\n\n### Setup\n\n1. **Clone the repository**:\n```bash\ngit clone \u003crepository-url\u003e\ncd agentic_rag\n```\n\n2. **Create a virtual environment**:\n```bash\npython3 -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. **Install dependencies**:\n```bash\npip install -r requirements.txt\n```\n\n4. **Configure environment variables**:\n```bash\ncp .env.example .env\n# Edit .env and add your OpenAI API key\n```\n\n### Quick Start\n\nUse the quick start script:\n```bash\n./examples/quick_start.sh\n```\n\nOr manually:\n```bash\n# Index sample documents\npython3 main.py index data/raw\n\n# Start interactive query mode\npython3 main.py query\n\n# Or ask a single question\npython3 main.py query \"What is machine learning?\"\n```\n\n## Usage\n\n### Command Line Interface\n\nThe CLI provides several commands:\n\n#### 1. Index Documents\n\nIndex documents from a file or directory:\n```bash\npython3 main.py index \u003cpath\u003e [--recreate]\n```\n\nExamples:\n```bash\n# Index a directory\npython3 main.py index ./data/raw\n\n# Recreate index from scratch\npython3 main.py index ./data/raw --recreate\n\n# Index a single file\npython3 main.py index ./document.pdf\n```\n\n#### 2. Query the System\n\nInteractive mode:\n```bash\npython3 main.py query\n```\n\nSingle query:\n```bash\npython3 main.py query \"What are the types of machine learning?\"\n```\n\n#### 3. System Information\n\nShow collection statistics:\n```bash\npython3 main.py info\n```\n\nPerform health check:\n```bash\npython3 main.py health\n```\n\n#### 4. Reset Index\n\nDelete the vector store index:\n```bash\npython3 main.py reset\n```\n\n### Programmatic Usage\n\n```python\nfrom src.core.orchestrator import create_orchestrator\nfrom pathlib import Path\nimport asyncio\n\nasync def main():\n    # Create orchestrator\n    orchestrator = create_orchestrator(enable_checkpointing=True)\n\n    # Index documents\n    result = orchestrator.index_documents(\n        source_path=Path(\"data/raw\"),\n        is_directory=True\n    )\n    print(f\"Indexed {result['documents_indexed']} chunks\")\n\n    # Query the system\n    query_result = await orchestrator.query(\n        query=\"What is supervised learning?\",\n        thread_id=\"conversation_001\"\n    )\n\n    print(f\"Answer: {query_result['answer']}\")\n    print(f\"Sources: {query_result['sources']}\")\n    print(f\"Confidence: {query_result['evaluation'].confidence}\")\n\nasyncio.run(main())\n```\n\n### Batch Processing\n\nProcess multiple queries:\n```python\nqueries = [\n    \"What is machine learning?\",\n    \"Explain supervised learning\",\n    \"What are the applications?\"\n]\n\nresults = await orchestrator.batch_query(queries, thread_id_prefix=\"batch\")\n\nfor i, result in enumerate(results):\n    print(f\"Q{i+1}: {queries[i]}\")\n    print(f\"A{i+1}: {result['answer']}\\n\")\n```\n\n## Configuration\n\nConfiguration is managed through environment variables and the `config/config.py` file.\n\n### Environment Variables (.env)\n\n```bash\n# OpenAI Configuration\nOPENAI_API_KEY=your_api_key_here\nOPENAI_MODEL=gpt-4-turbo-preview\nOPENAI_EMBEDDING_MODEL=text-embedding-3-small\n\n# Vector Store\nVECTOR_STORE_TYPE=chroma\nVECTOR_STORE_PATH=./data/vector_store\nCOLLECTION_NAME=agentic_rag_collection\n\n# LangGraph\nENABLE_DURABLE_EXECUTION=true\nCHECKPOINT_BACKEND=sqlite\nCHECKPOINT_PATH=./data/checkpoints.db\n\n# Agent Settings\nMAX_RETRIES=3\nTIMEOUT_SECONDS=60\n\n# Retrieval\nTOP_K_DOCUMENTS=5\nSIMILARITY_THRESHOLD=0.7\nCHUNK_SIZE=1000\nCHUNK_OVERLAP=200\n```\n\n## Project Structure\n\n```\nagentic_rag/\n├── config/\n│   └── config.py              # Configuration management\n├── src/\n│   ├── agents/\n│   │   ├── query_analyzer.py  # Query analysis agent\n│   │   ├── retriever.py       # Document retrieval agent\n│   │   ├── synthesizer.py     # Answer synthesis agent\n│   │   └── evaluator.py       # Quality evaluation agent\n│   ├── core/\n│   │   ├── document_loader.py # Document processing\n│   │   ├── vector_store.py    # Vector store management\n│   │   ├── workflow.py        # LangGraph workflow\n│   │   └── orchestrator.py    # Main orchestrator\n│   └── utils/\n├── data/\n│   ├── raw/                   # Input documents\n│   ├── processed/             # Processed documents\n│   └── vector_store/          # Vector database\n├── examples/\n│   ├── sample_usage.py        # Usage examples\n│   └── quick_start.sh         # Quick start script\n├── main.py                    # CLI interface\n├── requirements.txt           # Dependencies\n├── .env.example              # Environment template\n└── README.md                 # This file\n```\n\n## How It Works\n\n### 1. Document Indexing\n\nDocuments are processed through these steps:\n1. **Loading**: Support for PDF, TXT, DOCX, and other formats\n2. **Chunking**: Split into overlapping chunks (default: 1000 chars with 200 overlap)\n3. **Embedding**: Convert to vector embeddings using OpenAI\n4. **Storage**: Store in ChromaDB vector database\n\n### 2. Query Processing Workflow\n\nWhen a query is received:\n\n1. **Query Analysis**: The Query Analyzer Agent:\n   - Identifies the intent (factual, exploratory, analytical)\n   - Extracts key entities\n   - Reformulates the query for better retrieval\n   - Determines if multi-step reasoning is needed\n\n2. **Document Retrieval**: The Retrieval Agent:\n   - Performs similarity search on the vector store\n   - Uses the reformulated query\n   - Applies similarity thresholds\n   - Optional reranking for better relevance\n\n3. **Answer Synthesis**: The Synthesis Agent:\n   - Generates a comprehensive answer\n   - Cites sources properly\n   - Maintains context from retrieved documents\n   - Suggests follow-up questions\n\n4. **Quality Evaluation**: The Evaluation Agent:\n   - Scores the answer on multiple dimensions:\n     - Relevance (0-1)\n     - Completeness (0-1)\n     - Accuracy (0-1)\n     - Clarity (0-1)\n   - Checks for hallucinations\n   - Determines if regeneration is needed\n   - Approves or rejects the answer\n\n5. **Retry Logic**: If the answer is rejected:\n   - Retry synthesis with adjusted parameters\n   - Or retry retrieval with expanded queries\n   - Up to configurable max retries\n\n### 3. Durable Execution\n\nLangGraph's checkpointing ensures:\n- **State Persistence**: All workflow states are saved\n- **Crash Recovery**: Resume from last checkpoint after failures\n- **Debugging**: Inspect intermediate states\n- **Thread Management**: Track multiple conversations\n\n## Advanced Features\n\n### Custom Agents\n\nCreate custom agents by extending base classes:\n\n```python\nfrom src.agents.base import BaseAgent\n\nclass CustomAgent(BaseAgent):\n    def process(self, input_data):\n        # Your custom logic\n        return result\n```\n\n### Custom Workflow Nodes\n\nAdd custom nodes to the workflow:\n\n```python\ndef custom_node(state: AgenticRAGState) -\u003e AgenticRAGState:\n    # Your custom processing\n    state[\"custom_field\"] = process_data(state)\n    return state\n\nworkflow.add_node(\"custom_step\", custom_node)\nworkflow.add_edge(\"analyze_query\", \"custom_step\")\n```\n\n### Custom Evaluation Metrics\n\nDefine custom evaluation criteria:\n\n```python\nevaluator = EvaluationAgent(approval_threshold=0.8)\n# Or implement custom evaluation logic\n```\n\n## Performance Considerations\n\n- **Chunk Size**: Smaller chunks (500-1000 chars) work better for precise queries\n- **Top-K Documents**: Start with 5, increase if answers lack context\n- **Similarity Threshold**: Adjust (0.6-0.8) based on domain specificity\n- **Model Selection**: GPT-4 for complex reasoning, GPT-3.5 for speed\n- **Caching**: Vector store results are cached for repeated queries\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"Vector store not initialized\"**\n   - Solution: Run `python3 main.py index \u003cpath\u003e` first\n\n2. **Low quality answers**\n   - Increase `TOP_K_DOCUMENTS` in .env\n   - Lower `SIMILARITY_THRESHOLD`\n   - Use better quality source documents\n\n3. **Slow performance**\n   - Reduce `TOP_K_DOCUMENTS`\n   - Use smaller embedding model\n   - Enable caching\n\n4. **API rate limits**\n   - Increase `TIMEOUT_SECONDS`\n   - Reduce batch sizes\n   - Add retry delays\n\n## Examples\n\nSee `examples/sample_usage.py` for detailed examples including:\n- Basic indexing and querying\n- Batch query processing\n- Conversation tracking with thread IDs\n- Health checks and monitoring\n- Collection management\n\n## Contributing\n\nContributions are welcome! Please:\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n\n## Citation\n\nIf you use this project in your research or work, please cite:\n\n```bibtex\n@software{agentic_rag,\n  title = {Agentic RAG Pipeline: Multi-Agent Document Q\u0026A System},\n  author = Sai Kumar Yava,\n  year = {2024},\n  url = {https://github.com/scionoftech/agentic_rag}\n}\n```\n\n## Support\n\nFor issues, questions, or contributions, please:\n- Open an issue on GitHub\n- Check existing documentation\n- Review examples in the `examples/` directory\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscionoftech%2Fagentic_rag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscionoftech%2Fagentic_rag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscionoftech%2Fagentic_rag/lists"}