Canon-only RAG: single-pass retrieval, canon DB, port config - #10
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— pinMEMORYALPHA_DB_RELEASEto v0.5.2 (Tier 2 strict canon-only DB; non-canon real-world pages dropped upstream inmemoryalpha-vectordb). Text collection is now ~24.8k canon docs (was 37.5k).api/memoryalpha/rag.py— single-pass no-toolsask()/ask_stream()(retrieve → cross-encoder rerank → stuff → generate) with real token counts; the legacy tool-calling loop is preserved behindask_with_tools().api/memoryalpha/ask.py—GET/POST /memoryalpha/rag/askandGET/POST /memoryalpha/rag/stream..env/docker-compose.yml/chat.sh— split container-internalAPP_PORT(default8000) from host-publishedAPI_PORT(default18000), so the published mapping and the uvicorn listen port can't drift.chat.shtargetsAPP_PORTwith aRAG_API_URLoverride for host use.wait-for-ollama.sh— fix empty-model handling when pullingDEFAULT_MODEL.README.md— document endpoints, host-vs-container ports, and canon filtering.Validation
Rebuilt the devcontainer on v0.5.2 and ran live queries:
Notes