feat: add OrcaRouter as a named embedding provider - #1252
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: XiaoHuo888 <sjh00112233@outlook.com>
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a48c61f00
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| dimensions=dimensions, | ||
| api_key=api_key, | ||
| base_url=base_url or ORCAROUTER_DEFAULT_BASE_URL, | ||
| timeout=timeout, |
There was a problem hiding this comment.
Forward OrcaRouter dimensions before declaring 1536
When semantic_embedding_provider=orcarouter uses the default model, this constructor records dimensions=1536 only as Basic Memory's expected vector size, but the inherited embed_documents() call never sends a dimensions parameter to OrcaRouter. OrcaRouter's current model card for openai/text-embedding-3-small documents a 512-dimensional default unless a dimension is requested, so the normal bm reindex --embeddings path will create/expect 1536-dimensional vector storage and then fail on the first 512-dimensional response with the provider's dimension-mismatch error. Please either request dimensions=self.dimensions for OrcaRouter models that support it or fail fast unless the configured dimensions match the gateway default.
Useful? React with 👍 / 👎.
Summary
OrcaRouter is an OpenAI-compatible model routing gateway that brings 150+ models from OpenAI, Anthropic, Google, DeepSeek, Qwen, MiniMax and xAI behind a single endpoint and API key. Beyond routing, it runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes. This PR registers it as a named embedding provider so users can opt in directly.
I'm an engineer on the OrcaRouter team.
What this changes
src/basic_memory/repository/orcarouter_provider.py: newOrcaRouterEmbeddingProvider, mirroringOpenAIEmbeddingProviderbut pointed athttps://api.orcarouter.ai/v1and authenticated withORCAROUTER_API_KEY(keys start withsk-orca-).src/basic_memory/repository/embedding_provider_factory.py: registersorcarouterin both the provider factory dispatch and the provider identity resolver, withopenai/text-embedding-3-smallas the default model (1536 dimensions).src/basic_memory/config_models.py: documents theorcaroutervalue forsemantic_embedding_provider.docs/semantic-search.md: adds the OrcaRouter provider section and updates the config reference table.tests/repository/test_orcarouter_provider.py: covers lazy client construction, explicit key/base-url override, dimension mismatch, missing dependency, missing key, and factory selection/identity.Why this provider
The repo already treats
openaias a named embedding provider wired directly to a single endpoint. OrcaRouter is the same OpenAI-compatible wire, but the endpoint, key, and routing stay gateway-managed, so users get the standardprovider/modelmodel ids (e.g.openai/text-embedding-3-small) through oneORCAROUTER_API_KEY.How to use it
How this was tested
tests/repository/test_orcarouter_provider.py+ existingtest_openai_provider.py— 40 passed; fulltests/repository/suite — 605 passed, 29 skipped.ruff checkclean,ruff format --checkclean,ty checkclean on changed files.ORCAROUTER_API_KEY, the PR'dcreate_embedding_provider(provider="orcarouter")path returned 1536-dim vectors for bothembed_queryandembed_documentsthroughhttps://api.orcarouter.ai/v1/embeddings; provider identity resolves toOrcaRouterEmbeddingProvider:openai/text-embedding-3-small:1536.Related issues
None.