{"id":32519535,"url":"https://github.com/gatamar/rag-harry-potter","last_synced_at":"2026-05-06T01:34:37.288Z","repository":{"id":320738343,"uuid":"1083136569","full_name":"gatamar/rag-harry-potter","owner":"gatamar","description":"My second RAG, this time for the Harry Potter book, powered by Cursor+Codex ","archived":false,"fork":false,"pushed_at":"2025-10-25T14:33:04.000Z","size":23,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-25T16:25:33.603Z","etag":null,"topics":["faiss-cpu","openai","python","rag"],"latest_commit_sha":null,"homepage":"","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/gatamar.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-10-25T12:22:14.000Z","updated_at":"2025-10-25T14:35:21.000Z","dependencies_parsed_at":"2025-10-25T16:25:47.333Z","dependency_job_id":"1f012f45-368b-4c06-8d7e-285bec39f836","html_url":"https://github.com/gatamar/rag-harry-potter","commit_stats":null,"previous_names":["gatamar/rag-harry-potter"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/gatamar/rag-harry-potter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatamar%2Frag-harry-potter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatamar%2Frag-harry-potter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatamar%2Frag-harry-potter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatamar%2Frag-harry-potter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gatamar","download_url":"https://codeload.github.com/gatamar/rag-harry-potter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gatamar%2Frag-harry-potter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281386562,"owners_count":26492014,"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-10-28T02:00:06.022Z","response_time":60,"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":["faiss-cpu","openai","python","rag"],"created_at":"2025-10-28T04:28:52.450Z","updated_at":"2025-11-03T16:03:51.888Z","avatar_url":"https://github.com/gatamar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ✨ Harry Potter RAG (Educational Demo)\n\nWelcome to a local Retrieval-Augmented Generation walkthrough built around *Harry Potter and the Sorcerer's Stone*. This project is intentionally educational: it shows how to parse an EPUB, build a vector index, wire tracing/logging, and surface answers with LangChain—*all on your laptop*.\n\n## 🛠️ Tech Stack\n\n- **Python 3.11** for all scripts and tooling.\n- **ebooklib + BeautifulSoup + lxml** to parse the EPUB into JSONL chunks with provenance metadata.\n- **SentenceTransformers + FAISS** for dense embeddings and similarity search.\n- **LangChain 0.2** for retriever → prompt → LLM orchestration.\n- **OpenTelemetry + Jaeger** for local tracing across parsing, embedding, retrieval, and answer synthesis.\n- **SQLite** as a retrieval ledger capturing every query and its candidate set.\n\n## ⚙️ How It Works (example)\n\n```bash\n(venv) olia@macbookpro-1 rag-harry-potter % python tools/answer.py \"who was Harry teachers? list 5\"\nhuggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\nTo disable this warning, you can either:\n\t- Avoid using `tokenizers` before the fork if possible\n\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\nhuggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\nTo disable this warning, you can either:\n\t- Avoid using `tokenizers` before the fork if possible\n\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\nHarry's teachers included:\n\n1. Professor McGonagall - Transfiguration (chunk: index_split_008.html-0002)\n2. Professor Quirrell - Defense Against the Dark Arts (chunk: index_split_005.html-0008)\n3. Professor Flitwick - Charms (chunk: index_split_008.html-0002)\n4. Professor Binns - History of Magic (chunk: index_split_008.html-0002)\n5. Professor Snape - Potions (chunk: index_split_007.html-0014)\n\nContext chunks:\n- index_split_008.html-0002 (score=0.5514)\n- index_split_005.html-0008 (score=0.4642)\n- index_split_007.html-0014 (score=0.4602)\n- index_split_014.html-0001 (score=0.4580)\n- index_split_005.html-0020 (score=0.4526)\n```\n\nThe CLI loads the FAISS index, retrieves the top similarity hits, injects them into the answer prompt, and formats a response with chunk references. Traces are emitted to Jaeger (so you can inspect spans like `rag.answer.embed` and `rag.answer.llm`).\n\n## 🚀 Getting Started\n\n1. **Create a Python 3.11 environment** and install dependencies (`pip install -r requirements.txt`).\n2. **Initialize artifacts:** run `python flows/rag_pipeline.py` to parse and index the EPUB.\n3. **Set credentials:** place your OpenAI key (or local provider settings) in a `.env` file (`OPENAI_API_KEY=...`).\n4. **Start Jaeger** locally (`./tools/jaeger/jaeger-all-in-one --config=file:telemetry/jaeger-config.yaml`) to capture OpenTelemetry spans.\n5. **Ask a question:** `python tools/answer.py \"your question here\"`.\n\nThis repository is a learning sandbox—clone it, follow the design doc, and adapt it to your own corpus. Happy experimenting! 🧙‍♂️\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatamar%2Frag-harry-potter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgatamar%2Frag-harry-potter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgatamar%2Frag-harry-potter/lists"}