Skip to content

fix: embedding driver honors base_url override and embedding_base_url config (fixes #1212)#1249

Open
BunnyMoth wants to merge 1 commit into
RightNow-AI:mainfrom
BunnyMoth:fix/embedding-base-url-1212
Open

fix: embedding driver honors base_url override and embedding_base_url config (fixes #1212)#1249
BunnyMoth wants to merge 1 commit into
RightNow-AI:mainfrom
BunnyMoth:fix/embedding-base-url-1212

Conversation

@BunnyMoth

Copy link
Copy Markdown

Summary

Fixes #1212. The embedding driver hard-coded 6 cloud providers and
ignored all base_url override paths, forcing self-hosted deployments
to leak content to OpenAI cloud even when a local embedding server
was configured.

Root Cause

The embedding driver cached its URL at init and never consulted
[providers.openai].base_url or [provider_urls]. The needs_v1
allowlist also prevented non-listed providers from appending the
correct /v1/embeddings path suffix.

Changes

Three-tier URL resolution chain (kernel.rs)

All embedding driver init sites now resolve the URL through a
consistent chain:

  1. config.memory.embedding_base_url — new explicit embedding override
  2. config.provider_urls.get(provider) — existing per-provider override
  3. config.default_model.base_url when embedding provider matches
    the LLM provider — the missing link that caused the regression

New embedding_base_url field in MemoryConfig (config.rs)

[memory]
embedding_provider = "openai"
embedding_model = "nomic-embed-text-v1.5"
embedding_base_url = "http://my-llama-cpp:9080/v1"

Removed needs_v1 provider allowlist (embedding.rs)

Replaced the hard-coded allowlist with a simple trailing-slash trim.
The driver now trusts the URL the caller supplies, exactly like
OpenAIDriver does. Default URLs already carry the correct path suffix.

Testing

  • cargo fmt --all --check — clean
  • cargo clippy --workspace --all-targets -- -D warnings — zero warnings
  • cargo test --workspace — 997 tests, 0 failures
  • New tests: test_create_embedding_driver_openai_custom_base_url,
    test_create_embedding_driver_openai_custom_base_url_no_v1,
    test_create_embedding_driver_cohere_custom_url,
    test_create_embedding_driver_unknown_provider_custom_url

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.

Embedding driver hard-codes 6 cloud providers; OpenAI-compatible base_url override ignored (regression from #395 / #212 path for non-Ollama)

1 participant