Skip to content

fix: read EMBEDDING_API_BASE/KEY/DIMS in context_enhancer and bulk_wiki_ingest - #43

Open
johnkattenhorn wants to merge 1 commit into
ClaudioDrews:mainfrom
johnkattenhorn:fix/embedding-backend-env
Open

johnkattenhorn wants to merge 1 commit into
ClaudioDrews:mainfrom
johnkattenhorn:fix/embedding-backend-env

Conversation

@johnkattenhorn

@johnkattenhorn johnkattenhorn commented Oct 23, 2026 •

Copy link
Copy Markdown

Checklist

  • Follows existing code style
  • No new hardcoded paths or API keys (use env vars or .env.example)
  • Backward compatible (or breaking change is documented)
  • If adding a new file: python3 -m py_compile passes (no new files; both changed files compile)
  • If changing behavior: updated relevant docs in setup/ or layers/ (no doc change needed: .env.example, setup/install.md and layers/05-qdrant.md already describe these variables)

Description

The worker (docker/worker/services/embedding.py) already reads EMBEDDING_API_BASE, EMBEDDING_API_KEY and EMBEDDING_DIMS (#3, #7, #30). Two scripts still call https://openrouter.ai/api/v1/embeddings directly:

  • scripts/context_enhancer.py (embed_query, used for recall at query time)
  • scripts/bulk_wiki_ingest.py

With a non-OpenRouter embedding backend, ingestion embeds with one model and recall cannot embed at all, so recall silently falls back to lexical search.

This PR makes both scripts use the same settings as the worker. Defaults are unchanged: OpenRouter, OPENROUTER_API_KEY and 4096 dims. It also stops bulk_wiki_ingest.py from printing the first 20 characters of the API key; it prints the backend URL, model and dimensions instead.

We run this change in production against an OpenAI-compatible LiteLLM proxy.

Draft #35 covers the same gap in context_enhancer.py as part of a larger change (timeouts, retries, degraded-recall warnings). This PR is the minimal fix, and it also covers bulk_wiki_ingest.py. Close this one if you prefer to land #35.

Type

  • Bug fix
  • New feature
  • Performance improvement
  • Documentation
  • Refactor (no behavior change)
  • Security fix

Related issues

Follows #3, #7 and #30.

…ki_ingest

The worker (docker/worker/services/embedding.py) already reads
EMBEDDING_API_BASE, EMBEDDING_API_KEY and EMBEDDING_DIMS, but query-time
recall (context_enhancer.embed_query) and bulk_wiki_ingest still call
openrouter.ai directly. With a non-OpenRouter backend, ingestion embeds
with one model and recall cannot embed at all, so recall falls back to
lexical search. Defaults are unchanged: OpenRouter, OPENROUTER_API_KEY,
4096 dims.
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