Spaces:
Running
Running
|
Download rag/codemap.md from Deign86/mathpulse-api-v3test: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/spaces/Deign86/mathpulse-api-v3test/resolve/main/rag/codemap.md
- Command line
-
hf download hf://spaces/Deign86/mathpulse-api-v3test/rag/codemap.md
-
curl -L -o codemap.md https://huggingface.co/spaces/Deign86/mathpulse-api-v3test/resolve/main/rag/codemap.md
2.08 kB
| # backend/rag/ | |
| ## Responsibility | |
| Curriculum document parsing, ingestion, vector-store access, and retrieval of source-grounded lesson context. | |
| ## Design | |
| - `curriculum_rag.py` normalizes filters, builds Chroma queries, scores/organizes chunks, and formats lesson/problem prompts. | |
| - `vectorstore_loader.get_vectorstore_components` lazily initializes the Chroma collection and sentence-transformer embedder; health/reset helpers support diagnostics/tests. | |
| - `pdf_ingestion.ingest_pdf` extracts and chunks source PDFs, generates question/embedding data, and records processing state. | |
| - `liteparse_utils`, `pdf_parser`, and `docx_parser` isolate document parsing; `firebase_storage_loader` locates curriculum objects in Firebase Storage. | |
| - `teacher_module_generator.generate_teacher_module` builds structured teacher modules from retrieved material. | |
| ## Flow | |
| - `/api/rag/...` (`rag_routes` / `deepseek_rag_routes`) โ `retrieve_curriculum_context` or lesson retrieval helpers โ `get_vectorstore_components` โ Chroma `curriculum_chunks` โ formatted context โ inference/DeepSeek response. | |
| - `/api/curriculum/generate-module` โ `fun_modules_routes.generate_module` โ curriculum retrieval + `generate_teacher_module` โ structured module response. | |
| - Admin PDF reingestion โ `admin_routes` ingestion orchestration โ Firebase Storage/document parsing โ `pdf_ingestion.ingest_pdf` โ chunk/question and vector persistence. | |
| - Exact lesson retrieval uses `retrieve_lesson_pdf_context` / `build_exact_lesson_query`; generic retrieval uses `retrieve_curriculum_context` and metadata filters. | |
| ## Integration | |
| - Route consumers live under `backend/routes/`; model access is shared through `services.ai_client` / `services.inference_client`. | |
| - Source PDFs can be loaded from Firebase Storage; retrieval uses the local/configured Chroma vector store and `BAAI/bge-small-en-v1.5`-style sentence-transformer embeddings. | |
| - Firestore is used by ingestion for manifests/question metadata where configured; Chroma is the retrieval index, not the API router's persistence layer. | |