Skip to content

Canon-only RAG: single-pass retrieval, canon DB, port config - #10

Merged
aniongithub merged 2 commits into
mainfrom
canon-only-rag
Aug 17, 2026
Merged

Canon-only RAG: single-pass retrieval, canon DB, port config#10
aniongithub merged 2 commits into
mainfrom
canon-only-rag

Conversation

@aniongithub

Copy link
Copy Markdown
Owner

Summary

Pins the vector DB to the canon-filtered release and simplifies the RAG path to a single-pass retrieve → rerank → generate flow, plus fixes container port handling so the chat client and API always agree.

Changes

  • Dockerfile — pin MEMORYALPHA_DB_RELEASE to v0.5.2 (Tier 2 strict canon-only DB; non-canon real-world pages dropped upstream in memoryalpha-vectordb). Text collection is now ~24.8k canon docs (was 37.5k).
  • api/memoryalpha/rag.py — single-pass no-tools ask() / ask_stream() (retrieve → cross-encoder rerank → stuff → generate) with real token counts; the legacy tool-calling loop is preserved behind ask_with_tools().
  • api/memoryalpha/ask.pyGET/POST /memoryalpha/rag/ask and GET/POST /memoryalpha/rag/stream.
  • .env / docker-compose.yml / chat.sh — split container-internal APP_PORT (default 8000) from host-published API_PORT (default 18000), so the published mapping and the uvicorn listen port can't drift. chat.sh targets APP_PORT with a RAG_API_URL override for host use.
  • wait-for-ollama.sh — fix empty-model handling when pulling DEFAULT_MODEL.
  • README.md — document endpoints, host-vs-container ports, and canon filtering.

Validation

Rebuilt the devcontainer on v0.5.2 and ran live queries:

  • DB: `memoryalpha_text` = 24,817 docs; non-canon confirmed absent (The Pegasus (episode), Gauntlet, Patrick Stewart); canon present (Jean-Luc Picard, Transporter, Prime Directive).
  • "Who is Captain Picard?" / "What is the Prime Directive?" / "Who is Sarek?" → clean canonical in-universe answers, no novel/comic/reference-book pollution.

Notes

  • Image (CLIP) collection is empty in v0.5.2 (Fandom blocks image fetches from datacenter IPs in CI) — tracked as a follow-up in `memoryalpha-vectordb`. The text RAG path doesn't use it.

Pin the vector DB to the canon-filtered release and simplify the RAG
path to a single-pass retrieve-rerank-generate flow, plus fix container
port handling so the chat client and API agree.

- Dockerfile: pin MEMORYALPHA_DB_RELEASE to v0.5.2 (Tier 2 strict
  canon-only DB; non-canon real-world pages dropped upstream).
- rag.py: single-pass no-tools ask()/ask_stream() (retrieve -> rerank ->
  stuff -> generate) with real token counts; legacy tool loop kept behind
  ask_with_tools().
- ask.py: GET/POST /memoryalpha/rag/ask and /memoryalpha/rag/stream.
- .env/docker-compose.yml/chat.sh: split container-internal APP_PORT
  (default 8000) from host-published API_PORT (default 18000) so the
  published mapping and uvicorn listen port cannot drift; chat.sh targets
  APP_PORT with a RAG_API_URL override.
- wait-for-ollama.sh: fix empty-model handling when pulling DEFAULT_MODEL.
- README: document endpoints, ports, and canon filtering.
The committed .env now sets API_PORT=18000, and docker compose reads it
for the host port mapping, so the published port is no longer always
8000. Source .env and target ${API_PORT:-8000} in the workflow curls
(health readiness, ask endpoint, OpenAPI spec) across pr-check, ci-build,
and release so CI tests the actually-published port.
@aniongithub
aniongithub merged commit da921ca into main Aug 17, 2026
1 check passed
@aniongithub
aniongithub deleted the canon-only-rag branch August 17, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant