Skip to content

feat(memory-lancedb): support custom OpenAI-compatible embedding providers#20771

Closed
marcodelpin wants to merge 1 commit intoopenclaw:mainfrom
marcodelpin:feat/memory-lancedb-custom-embeddings
Closed

feat(memory-lancedb): support custom OpenAI-compatible embedding providers#20771
marcodelpin wants to merge 1 commit intoopenclaw:mainfrom
marcodelpin:feat/memory-lancedb-custom-embeddings

Conversation

@marcodelpin
Copy link
Copy Markdown

@marcodelpin marcodelpin commented Feb 19, 2026

Summary

Adds baseUrl and dimensions configuration to the memory-lancedb plugin, enabling use of any OpenAI-compatible embedding endpoint instead of being locked to OpenAI's API.

This allows users to run memory embeddings with:

  • Ollama (http://localhost:11434/v1)
  • LM Studio (local endpoint)
  • vLLM / text-generation-inference
  • Custom ONNX Runtime servers
  • Any other OpenAI-compatible embedding API

Changes

config.ts

  • Added baseUrl?: string and dimensions?: number to MemoryConfig.embedding type
  • vectorDimsForModel() now accepts optional configDimensions fallback — unknown models work when dimensions are specified in config
  • parse() passes through baseUrl and dimensions to the returned config (previously these were silently dropped)
  • Updated assertAllowedKeys to accept the new fields
  • Added uiHints for baseUrl and dimensions (marked as advanced)

index.ts

  • Embeddings constructor accepts optional baseUrl and passes it to new OpenAI({ apiKey, baseURL })
  • register() passes cfg.embedding.baseUrl and cfg.embedding.dimensions through to the relevant constructors

openclaw.plugin.json

  • Removed hardcoded enum restriction on embedding model — any string is now accepted
  • Added baseUrl and dimensions properties to the JSON schema with descriptions
  • Updated uiHints labels/help text

index.test.ts

  • Added 3 new tests:
    • Custom baseUrl + dimensions config is accepted
    • Known model works without dimensions
    • Unknown model without dimensions throws a helpful error

Example Configuration

// Local Ollama embeddings
{
  "embedding": {
    "apiKey": "ollama",
    "model": "nomic-embed-text",
    "baseUrl": "http://localhost:11434/v1",
    "dimensions": 768
  }
}

// Local ONNX Runtime server
{
  "embedding": {
    "apiKey": "local",
    "model": "multilingual-e5-base",
    "baseUrl": "http://localhost:11434/v1",
    "dimensions": 768
  }
}

// OpenAI (unchanged, backwards compatible)
{
  "embedding": {
    "apiKey": "sk-proj-...",
    "model": "text-embedding-3-small"
  }
}

Backwards Compatibility

  • Fully backwards compatible — existing configs without baseUrl/dimensions work exactly as before
  • Known models (text-embedding-3-small, text-embedding-3-large) don't need dimensions
  • baseUrl defaults to OpenAI's endpoint when not specified

Test plan

  • All 9 existing tests pass
  • 3 new tests added for custom config
  • Tested end-to-end with local ONNX Runtime embedding server on CUDA GPU (multilingual-e5-base, 768 dims)
  • Verify with Ollama embedding endpoint
  • Verify with LM Studio

Closes #8118
Closes #17564

🤖 Generated with Claude Code
Testing: fully tested (automated + manual verification)
I understand and can explain all changes in this PR.

Greptile Summary

Adds support for custom OpenAI-compatible embedding providers (Ollama, LM Studio, vLLM) by introducing baseUrl and dimensions configuration options. The implementation correctly handles backwards compatibility, validates unknown models require explicit dimensions, and passes configuration through all layers (schema → parser → constructor). Three new tests cover the key scenarios: custom providers with dimensions, known models without dimensions, and proper error handling for unknown models without dimensions.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured, maintain backwards compatibility, include comprehensive test coverage (3 new tests for the new functionality), and follow existing code patterns. The implementation correctly validates that unknown models require explicit dimensions, properly passes configuration through all layers, and doesn't introduce breaking changes to existing configurations.
  • No files require special attention

Last reviewed commit: 0f4059b

@openclaw-barnacle openclaw-barnacle bot added extensions: memory-lancedb Extension: memory-lancedb size: S labels Feb 19, 2026
@marcodelpin marcodelpin force-pushed the feat/memory-lancedb-custom-embeddings branch 2 times, most recently from e521dc2 to 285fa49 Compare February 19, 2026 09:21
@marcodelpin
Copy link
Copy Markdown
Author

CI note: The check failure is unrelated to this PR — oxfmt --check flags formatting issues in src/infra/fs-safe.ts and src/web/media.ts, which are pre-existing in main and not touched by this changeset.

Add baseUrl and dimensions config options to the memory-lancedb plugin,
enabling use of any OpenAI-compatible embedding API (Ollama, LM Studio,
vLLM, etc.) with custom models.

Changes:
- Add embedding.baseUrl config for custom API endpoints
- Add embedding.dimensions config for non-built-in models
- Pass baseUrl through to OpenAI client constructor (fixes openclaw#8118)
- Remove hardcoded model enum from plugin JSON schema
- Update vectorDimsForModel to accept config-provided dimensions
- Add 3 new tests for custom embedding configuration

Closes openclaw#8118
Ref openclaw#17564
@marcodelpin marcodelpin force-pushed the feat/memory-lancedb-custom-embeddings branch from 70dd38f to 6042c70 Compare February 19, 2026 11:57
@openclaw-barnacle openclaw-barnacle bot removed the channel: whatsapp-web Channel integration: whatsapp-web label Feb 19, 2026
@sstidl
Copy link
Copy Markdown

sstidl commented Feb 22, 2026

this would also enable us to use azure openai / foundry deployments for embedding models, right?

@marcodelpin
Copy link
Copy Markdown
Author

Yes, this covers Azure OpenAI and Foundry deployments as well — the baseUrl passthrough works with any OpenAI-compatible endpoint, including Azure's.

@vincentkoc
Copy link
Copy Markdown
Member

Nice work on this implementation.

I am closing it as a duplicate of #17874, now merged as the canonical fix for this memory-lancedb embedding provider overlap.

If you see a concrete gap that #17874 does not cover, point it out and we can reopen review.

@vincentkoc vincentkoc added dedupe:child Duplicate issue/PR child in dedupe cluster close:duplicate Closed as duplicate labels Feb 27, 2026
@vincentkoc vincentkoc closed this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster extensions: memory-lancedb Extension: memory-lancedb size: S

Projects

None yet

3 participants