{"id":28458710,"url":"https://github.com/openmined/rag-router-demo","last_synced_at":"2025-08-30T20:06:21.061Z","repository":{"id":292019371,"uuid":"972758456","full_name":"OpenMined/rag-router-demo","owner":"OpenMined","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-23T10:08:03.000Z","size":87,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-26T03:09:20.984Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenMined.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":"openmined","open_collective":"openmined"}},"created_at":"2025-04-25T16:00:30.000Z","updated_at":"2025-06-23T10:08:06.000Z","dependencies_parsed_at":"2025-05-07T18:43:31.202Z","dependency_job_id":"17bec2ae-e838-4a8a-8dbd-b7fd68139b3f","html_url":"https://github.com/OpenMined/rag-router-demo","commit_stats":null,"previous_names":["openmined/rag-router-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OpenMined/rag-router-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Frag-router-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Frag-router-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Frag-router-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Frag-router-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenMined","download_url":"https://codeload.github.com/OpenMined/rag-router-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenMined%2Frag-router-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272900157,"owners_count":25012033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-06-07T00:39:36.221Z","updated_at":"2025-08-30T20:06:20.988Z","avatar_url":"https://github.com/OpenMined.png","language":"Python","funding_links":["https://github.com/sponsors/openmined","https://opencollective.com/openmined"],"categories":[],"sub_categories":[],"readme":"# RAG Router Implementation\n\nA Syft-based RAG (Retrieval-Augmented Generation) router implementation that provides a unified interface for LLM interactions, document retrieval, and embedding management.\n\n## Features\n\n- **Unified LLM Interface**: Support for both chat and completion endpoints\n- **Document Retrieval**: Integrated RAG capabilities with vector search\n- **Embedding Management**: Automatic document embedding and indexing\n- **Event-Driven Architecture**: Built on SyftEvents for scalable processing\n- **Rate Limiting**: Configurable rate limits for API endpoints\n- **Extensible Design**: Easy to add new LLM providers and retrieval strategies\n\n## Project Structure\n\n```\n.\n├── pyproject.toml      # Project dependencies and configuration\n├── run.sh             # Service startup script\n├── router.py          # RAG router implementation\n├── server.py          # Server implementation\n└── chat_test.py       # Example chat implementation\n```\n\n## Prerequisites\n\n- Python 3.12 or higher\n- uv (Python package manager)\n- Access to a Syft network\n\n## Installation\n\n1. Install uv (if not already installed):\n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\n2. Clone the repository and install dependencies:\n```bash\ngit clone \u003crepository-url\u003e\ncd rag-router-demo\nuv pip install -e .\n```\n\n## Configuration\n\nThe application can be configured through the `pyproject.toml` file:\n\n```toml\n[tool.rag-app]\n# Rate limiting settings\nenable_rate_limiting = true\nrequests_per_minute = 1\nrequests_per_hour = 10\nrequests_per_day = 1000\n\n# Embedding settings\nembedder_endpoint = \"\"\nindexer_endpoint = \"\"\n\n# Retrieval settings\nretriever_endpoint = \"\"\n```\n\n## Running the Service\n\nStart the service using the provided script:\n\n```bash\n./run.sh\n```\n\nThe script will:\n1. Create a Python virtual environment\n2. Install all dependencies\n3. Start the server with the specified project name\n\n## API Endpoints\n\n### Document Retrieval\n- `POST /retrieve`: Retrieve relevant documents\n  ```json\n  {\n    \"query\": \"string\",\n    \"options\": {\n      \"top_k\": 5,\n      \"score_threshold\": 0.7\n    }\n  }\n  ```\n\n### Health Check\n- `GET /ping`: Check service health\n\n## Document Embedding\n\nThe service automatically watches for new documents in the `{datasite}/embeddings` directory. When new JSON files are added, they are automatically:\n1. Chunked into appropriate sizes\n2. Embedded using the configured embedder\n3. Indexed in the vector database\n\n## Development\n\n### Setting Up Development Environment\n\n1. Create and activate a virtual environment:\n```bash\nuv venv -p 3.12 .venv\nsource .venv/bin/activate\n```\n\n2. Install development dependencies:\n```bash\nuv pip install -e \".[dev]\"\n```\n\n### Adding New LLM Providers\n\nTo add a new LLM provider:\n1. Create a new class that inherits from `BaseLLMRouter`\n2. Implement the required methods:\n   - `generate_completion`\n   - `generate_chat`\n   - `retrieve_documents`\n   - `embed_documents`\n3. Update the `load_router()` function in `server.py`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Frag-router-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenmined%2Frag-router-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenmined%2Frag-router-demo/lists"}