Skip to content

feat(memory-lancedb): support Ollama and OpenAI-compatible embedding endpoints#17030

Closed
nightfullstar wants to merge 2 commits intoopenclaw:mainfrom
nightfullstar:feat/memory-lancedb-ollama-support
Closed

feat(memory-lancedb): support Ollama and OpenAI-compatible embedding endpoints#17030
nightfullstar wants to merge 2 commits intoopenclaw:mainfrom
nightfullstar:feat/memory-lancedb-ollama-support

Conversation

@nightfullstar
Copy link

@nightfullstar nightfullstar commented Feb 15, 2026

Summary

The memory-lancedb plugin previously required an OpenAI API key and only talked to OpenAI’s embeddings API. This PR adds support for Ollama and any other service that exposes the OpenAI-compatible /v1/embeddings API (e.g. local or self-hosted endpoints), so you can run long-term memory without an OpenAI key.

Scope

  • Config (config.ts): embedding.apiKey is now optional when embedding.baseUrl is set (e.g. Ollama). Added embedding.baseUrl (default https://api.openai.com/v1) and embedding.dimensions (for models not in the built-in list). Built-in dimensions extended with nomic-embed-text (768) and mxbai-embed-large (1024).
  • Embeddings (index.ts): Replaced the hardcoded openai client with a small fetch-based client that uses baseUrl and only sends Authorization when apiKey is set.
  • Tests (index.test.ts): Updated “missing apiKey” assertion to the new error message; added test that Ollama-style config (baseUrl + model, no apiKey) parses correctly.
  • Docs: Added OLLAMA-SUPPORT.md describing the change and how to use the plugin with Ollama.

User-facing changes

  • New config options: plugins.entries.memory-lancedb.config.embedding.baseUrl (e.g. http://localhost:11434/v1 for Ollama), embedding.dimensions (required for unknown models).
  • Optional API key: When baseUrl is set to a local/OpenAI-compatible endpoint (e.g. Ollama), embedding.apiKey can be omitted.
  • Existing OpenAI usage: Unchanged. Omit baseUrl (or leave default) and set embedding.apiKey as before.

Testing

  • pnpm test -- extensions/memory-lancedb/index.test.ts — all tests pass (including new Ollama config test).
  • Lint/format: pnpm check (no new issues).

Example (Ollama)

{
  "plugins": {
    "entries": {
      "memory-lancedb": {
        "config": {
          "embedding": {
            "baseUrl": "http://localhost:11434/v1",
            "model": "nomic-embed-text"
          },
          "dbPath": "~/.openclaw/memory/lancedb",
          "autoCapture": true,
          "autoRecall": true
        }
      }
    },
    "slots": { "memory": "memory-lancedb" }
  }
}

No apiKey required; run ollama pull nomic-embed-text and ensure Ollama is serving.

Greptile Summary

Adds support for Ollama and OpenAI-compatible embedding endpoints to the memory-lancedb plugin, allowing users to run long-term memory without an OpenAI API key. The implementation replaces the hardcoded OpenAI client with a generic fetch-based client that conditionally sends authorization headers when an API key is provided.

Changes made:

  • config.ts: Made embedding.apiKey optional when embedding.baseUrl is set, added embedding.baseUrl and embedding.dimensions config options, extended built-in dimension mappings for Ollama models (nomic-embed-text, mxbai-embed-large)
  • index.ts: Replaced OpenAI SDK with lightweight fetch implementation that works with any OpenAI-compatible /v1/embeddings endpoint
  • index.test.ts: Updated test assertions to match new error messages and added validation for Ollama configuration

Issues found:

  • The openai package dependency is still present in package.json but is no longer imported or used in the code

Confidence Score: 4/5

  • Safe to merge with minor cleanup recommended
  • The implementation is solid with proper validation, security considerations (UUID validation, prompt injection filtering), and comprehensive test coverage. The fetch-based approach correctly handles OpenAI-compatible endpoints. One non-critical improvement: removing the unused openai dependency from package.json.
  • Check extensions/memory-lancedb/package.json to remove unused dependency

Last reviewed commit: 8baa707

… Ollama

- Updated MemoryConfig to include optional baseUrl and dimensions for embedding.
- Modified vectorDimsForModel to accept explicit dimensions.
- Refactored resolveEmbeddingConfig to validate and resolve embedding settings.
- Adjusted Embeddings class to support OpenAI-compatible endpoints, including Ollama.
- Updated tests to validate new configuration options and ensure proper error handling for missing apiKey when using OpenAI.
@openclaw-barnacle openclaw-barnacle bot added extensions: memory-lancedb Extension: memory-lancedb size: S labels Feb 15, 2026
@nightfullstar nightfullstar marked this pull request as ready for review February 15, 2026 10:48
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 15, 2026

Additional Comments (1)

extensions/memory-lancedb/package.json
openai dependency should be removed since it's no longer imported/used in index.ts

    "@sinclair/typebox": "0.34.48"
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/memory-lancedb/package.json
Line: 10:10

Comment:
`openai` dependency should be removed since it's no longer imported/used in `index.ts`

```suggestion
    "@sinclair/typebox": "0.34.48"
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Additional Comments (1)

extensions/memory-lancedb/package.json
openai dependency no longer used (replaced with fetch in index.ts:176-194), can be removed

  }
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/memory-lancedb/package.json
Line: 10:10

Comment:
`openai` dependency no longer used (replaced with `fetch` in `index.ts:176-194`), can be removed

```suggestion
  }
```

How can I resolve this? If you propose a fix, please make it concise.

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 22, 2026
@vincentkoc
Copy link
Member

Thanks for pushing this through.

I am closing this as a duplicate of #17874, which is now merged and covers the same memory-lancedb OpenAI-compatible embeddings path.

Your contribution is still part of the history for this area. If there is behavior here that #17874 missed, reply here and we can reopen quickly.

@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

Development

Successfully merging this pull request may close these issues.

3 participants