You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.**`rag/retrieve.py`** -- two-stage search: FAISS top-K (cosine via inner product on L2-normalized vectors), then cross-encoder reranking with sigmoid score normalization
33
-
4.**`config.py`** -- all tunable parameters (paths, model names, thresholds, retrieval K values, `ONNX_FILE_NAME` auto-detected per CPU architecture, `FEEDBACK_ENV` auto-detected from `SPACE_ID`)
34
-
5.**`app.py`** -- FastAPI server: loads pipeline in a background thread at startup (UI available immediately, `/search` returns a loading fragment with HTMX auto-retry until ready, `/health` returns 503 while loading). Query sanitization, input validation, contextual verse display with surrounding verses bounded by book_id. Root URL serves SPA, SEO routes (`/robots.txt`, `/sitemap.xml`), static asset cache middleware (24h), HF-to-custom-domain redirect middleware
33
+
4.**`config.py`** -- all tunable parameters (paths, model names, thresholds, retrieval K values, `SEARCH_CACHE_SIZE`, `ONNX_FILE_NAME` auto-detected per CPU architecture, `FEEDBACK_ENV` auto-detected from `SPACE_ID`)
34
+
5.**`app.py`** -- FastAPI server: loads pipeline in a background thread at startup (UI available immediately, `/search` returns a loading fragment with HTMX auto-retry until ready, `/health` returns 503 while loading). Query sanitization, input validation, contextual verse display with surrounding verses bounded by book_id. LRU cache on `_run_search_cached` (128 entries) makes repeated queries near-instant; `_run_search` returns shallow-copied dicts to prevent cache mutation. Root URL serves SPA, SEO routes (`/robots.txt`, `/sitemap.xml`), static asset cache middleware (24h), HF-to-custom-domain redirect middleware
35
35
6.**`rag/feedback.py`** -- per-verse feedback: thread-safe JSONL buffer with periodic flush to HuggingFace Dataset repo via `HfApi.upload_file()`. Config-driven thresholds and intervals. Lazy-imports `huggingface_hub` to avoid startup cost
36
36
37
37
Data flow: `bible.db` -> ingest -> `data/{index.faiss, mapping.json}` -> app startup spawns background thread to load into memory -> HTMX POST `/search` -> HTML fragment response (or loading fragment if pipeline not yet ready). Root `/` serves the SPA entry point. Feedback: `POST /feedback` -> append to JSONL buffer -> periodic flush to HF Dataset repo (production only).
0 commit comments