{"id":25193871,"url":"https://github.com/didibrabosa/ai-pdf-reader","last_synced_at":"2026-04-14T15:32:39.319Z","repository":{"id":274888714,"uuid":"924321223","full_name":"didibrabosa/ai-pdf-reader","owner":"didibrabosa","description":"AI-powered PDF Q\u0026A system using FastAPI, ChromaDB, and OpenAI. Extracts, indexes, and retrieves relevant text chunks to answer questions.","archived":false,"fork":false,"pushed_at":"2025-02-24T21:48:33.000Z","size":1470,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:45:13.340Z","etag":null,"topics":["ai","chromadb","chunks","dotenv","fastapi","gpt-4","langchain","openai","pydantic","pypdf2","python","uvicorn"],"latest_commit_sha":null,"homepage":"https://github.com/Piyush150398/RAG_Application","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/didibrabosa.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}},"created_at":"2025-01-29T19:46:38.000Z","updated_at":"2025-02-25T16:45:34.000Z","dependencies_parsed_at":"2025-02-24T22:22:28.563Z","dependency_job_id":"d525ddd1-b121-4e24-9328-3433b76364ad","html_url":"https://github.com/didibrabosa/ai-pdf-reader","commit_stats":null,"previous_names":["didibrabosa/ai-pdf-reader"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/didibrabosa/ai-pdf-reader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didibrabosa%2Fai-pdf-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didibrabosa%2Fai-pdf-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didibrabosa%2Fai-pdf-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didibrabosa%2Fai-pdf-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/didibrabosa","download_url":"https://codeload.github.com/didibrabosa/ai-pdf-reader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/didibrabosa%2Fai-pdf-reader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31803316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T11:13:53.975Z","status":"ssl_error","status_checked_at":"2026-04-14T11:13:53.299Z","response_time":153,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["ai","chromadb","chunks","dotenv","fastapi","gpt-4","langchain","openai","pydantic","pypdf2","python","uvicorn"],"created_at":"2025-02-09T23:22:56.285Z","updated_at":"2026-04-14T15:32:39.298Z","avatar_url":"https://github.com/didibrabosa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RAG PDF Reader\n\n## Project Description\nThe **RAG PDF Reader** is an application that implements a Retrieval-Augmented Generation (**RAG**) system using **FastAPI**. The app reads a specific PDF file (\"Harry Potter AI.pdf\"), extracts its text, splits it into **chunks**, and stores these chunks in a vector database with **ChromaDB**. When you ask a question, the system retrieves the most relevant text chunks and uses an **OpenAI** model to generate an answer.\n\n### How It Works\n1. Startup Process:\n   - The PDF file is read and its text is extracted.\n   - The extracted text is split into chunks.\n   - The chunks are stored in a ChromaDB collection.\n   - The response is returned to the user via a **FastAPI**.\n2. Query Processing:\n   - A POST request is sent to the /ask_ai endpoint with a question.\n   - The system retrieves the top 3 relevant chunks from the collection.\n   - The retrieved chunks are combined to form a context.\n   - The context and question are sent to an OpenAI model (gpt-4o-mini) to generate an answer.\n3. Shutdown Process:\n   - The ChromaDB collection is deleted to clean up the database.\n\n## Requirements\nTo run this project, install the following dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\nThe `requirements.txt` file includes:\n- **FastAPI**: Framework for building the API.\n- **uvicorn**: ASGI server for FastAPI.\n- **python-dotenv**: For managing environment variables.\n- **langchain**: Library for interacting with LLMs.\n- **langchain and langchain-openai**: For interacting with OpenAI models.\n- **chromadb**: Vector database for semantic searches.\n- **PyPDF2**: Library for reading PDFs.\n- **pydantic**: For data validation.\n\n## How to Use\n1. Set Up Your API Key: \n   - Create a .env file or set the environment variable OPENAI_API_KEY with your OpenAI API key. \n   - If not set, the application will prompt you to enter the key at startup.\n2. Select a PDF: \n   - Choose a PDF of your choice and reference the path or use the example bellow.\n3. Start the application by running:\n   ```bash\n   uvicorn main:app --reload\n   ```\n4. Ask a Question:\n   - Send a POST request to the /ask_ai endpoint with a JSON payload like:\n   ```json\n   {\n     \"question\": \"Your question about the PDF content\"\n   }\n   ```\n   The application will return an answer based on the extracted content from the PDF.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidibrabosa%2Fai-pdf-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidibrabosa%2Fai-pdf-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidibrabosa%2Fai-pdf-reader/lists"}