{"id":48834087,"url":"https://github.com/edwards359/rag-document-assistant","last_synced_at":"2026-04-14T22:05:05.794Z","repository":{"id":344890829,"uuid":"1183573715","full_name":"Edwards359/rag-document-assistant","owner":"Edwards359","description":"RAG‑ассистент для поиска по документам и контекстных ответов (RAG Document Assistant).","archived":false,"fork":false,"pushed_at":"2026-03-16T19:08:07.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-17T06:00:41.886Z","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/Edwards359.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":"2026-03-16T18:39:31.000Z","updated_at":"2026-03-16T19:24:33.000Z","dependencies_parsed_at":"2026-03-17T06:00:43.652Z","dependency_job_id":null,"html_url":"https://github.com/Edwards359/rag-document-assistant","commit_stats":null,"previous_names":["edwards359/rag-document-assistant"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Edwards359/rag-document-assistant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edwards359%2Frag-document-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edwards359%2Frag-document-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edwards359%2Frag-document-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edwards359%2Frag-document-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Edwards359","download_url":"https://codeload.github.com/Edwards359/rag-document-assistant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Edwards359%2Frag-document-assistant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31817137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"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-14T22:04:28.147Z","updated_at":"2026-04-14T22:05:05.725Z","avatar_url":"https://github.com/Edwards359.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 🇷🇺 Обзор для заказчика\n\n**RAG Document Assistant** — AI‑ассистент, который отвечает на вопросы по вашим документам.\n\n- **Для чего:** сократить ручной поиск по PDF, регламентам и инструкциям.\n- **Что делает:** принимает текст документов, разбивает их на фрагменты, находит релевантные части и формирует контекстный ответ.\n- **Где полезен:** внутренние базы знаний, HR/IT‑политики, product‑документация, инструкции для сотрудников.\n- **Пример кейса:** сотрудник задаёт вопрос по отпускной политике → ассистент возвращает ответ + выдержки из актуального документа.\n\nДальше в README показано:\n- как устроена архитектура RAG‑решения (ingestion → retrieval → answer),\n- какие эндпоинты есть в API,\n- как это может быть расширено до продакшн‑уровня (векторное хранилище, реальный LLM).\n\n---\n# RAG Document Assistant\n_Practical RAG-style document question answering API_\n\n## Overview\nRAG Document Assistant is a small, focused backend that demonstrates how to answer questions based on your own documents.  \nIt provides a simple API to ingest documents, split them into chunks, store them in memory, retrieve relevant chunks, and generate a contextual answer.\n\n## Business problem\nTeams lose time searching through PDFs, policies, and scattered documents.  \nEmployees either read long files manually or ping “the expert” for every question.\n\n## Solution\nThis project shows a clean, extensible RAG-style backend where:\n- documents are ingested and chunked,\n- relevant chunks are retrieved for each question,\n- a prompt layer combines question + context into a model-ready input,\n- the model generates a contextual answer.\n\nYou can plug in a real vector DB and LLM later — the architecture is already prepared for that.\n\n## Key features\n- **Document ingestion** via `/ingest`\n- **In-memory chunk store** (replaceable with any vector DB)\n- **Simple retrieval logic** based on keyword / scoring\n- **Context-aware answer generation** with a clear prompt layer\n- **FastAPI API** ready for integration into products or tools\n\n## Architecture\n\n```text\nUser\n  ↓\nFastAPI (POST /ask)\n  ↓\nRetriever\n  ↓\nDocument Chunks (in-memory store)\n  ↓\nPrompt Builder → LLM Client (mock or real)\n  ↓\nContextual Answer\n```\n\n## Tech stack\n- Python 3.11+\n- FastAPI\n- Pydantic\n- python-dotenv\n\n## API endpoints\n\n- `POST /ingest` — ingest a document as text\n- `POST /ask` — ask a question about ingested documents\n- `GET /health` — health check\n\n## Example request / response\n\n### POST /ingest\n\n```json\n{\n  \"document_id\": \"employee_handbook_v1\",\n  \"text\": \"Long text of your document goes here...\"\n}\n```\n\n### POST /ask\n\n**Request:**\n\n```json\n{\n  \"question\": \"What is the vacation policy?\",\n  \"top_k\": 3\n}\n```\n\n**Response (example):**\n\n```json\n{\n  \"question\": \"What is the vacation policy?\",\n  \"answer\": \"The handbook states that employees are entitled to 20 days of paid vacation per year...\",\n  \"context_chunks\": [\n    {\n      \"document_id\": \"employee_handbook_v1\",\n      \"chunk_id\": \"employee_handbook_v1-0\",\n      \"score\": 0.82,\n      \"text_preview\": \"Employees are entitled to 20 days of paid vacation per year...\"\n    }\n  ]\n}\n```\n\n## Example workflow\n1. Client ingests one or more documents via `/ingest`.\n2. The API splits them into chunks and stores them in an in-memory index.\n3. The user (or another service) calls `/ask` with a natural-language question.\n4. The retriever finds the most relevant chunks.\n5. The prompt layer builds an input for the LLM client.\n6. The LLM client (mock or real) returns a contextual answer.\n\n## RAG in this project\nRAG (Retrieval-Augmented Generation) here means:\n- **Retrieve**: select relevant document chunks for a question.\n- **Augment**: build a prompt that includes those chunks as context.\n- **Generate**: let the model answer using that context.\n\nThe retrieval is intentionally simple (in-memory, keyword-based) but the code is structured so that any vector database can be plugged in later.\n\n## Prompt engineering relevance\nThe answer quality heavily depends on how we:\n- frame the question + context,\n- instruct the model to ground its answer in the provided chunks,\n- ask it to point out when there is not enough information.\n\nThe `llm_client.py` and service layer make it easy to tweak prompts in one place.\n\n## Possible integrations\n- internal knowledge portals\n- admin panels (document management + Q\u0026A)\n- chatbots (Telegram, web widget) that call the `/ask` endpoint\n- workflow tools (e.g. n8n) that send documents and questions to this API\n\n## Project structure\n\n```text\nrag-document-assistant/\n  app/\n    __init__.py\n    main.py\n    config.py\n    schemas.py\n    routes.py\n    services/\n      __init__.py\n      rag_service.py\n      llm_client.py\n  data/\n    README.md\n  .env.example\n  .gitignore\n  requirements.txt\n  README.md\n```\n\n## Future improvements\n- Replace in-memory store with a real vector database (e.g. Chroma, FAISS, Pinecone).\n- Add support for multiple document formats (PDF, DOCX, HTML).\n- Add embeddings and similarity search.\n- Add authentication and per-tenant isolation.\n- Provide a small web UI or chat interface on top of the API.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwards359%2Frag-document-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwards359%2Frag-document-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwards359%2Frag-document-assistant/lists"}