← Back to PRs

#17566: memory-lancedb: support local OpenAI-compatible embeddings

by lumenradley open 2026-02-15 22:32 View on GitHub →
extensions: memory-lancedb size: M
## Summary - allow custom OpenAI-compatible embedding endpoints via `embedding.baseUrl` - allow custom model ids and explicit vector sizing via `embedding.dimensions` - switch embedding calls to raw OpenAI-compatible `/embeddings` HTTP for broader local-provider compatibility - enforce embedding dimension consistency at runtime to prevent LanceDB vector mismatch errors - extend tests for custom-model/dimensions/baseUrl validation paths ## Validation - `pnpm vitest run extensions/memory-lancedb/index.test.ts` ## Linked issue Closes https://github.com/openclaw/openclaw/issues/17564 <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds support for local OpenAI-compatible embedding endpoints in the `memory-lancedb` plugin by replacing the OpenAI SDK with raw `fetch` calls, adding `embedding.baseUrl` and `embedding.dimensions` configuration options, and enforcing dimension consistency at runtime. - Replaced `openai` SDK with raw HTTP `fetch` for broader local-provider compatibility (e.g., LM Studio, llama.cpp, vLLM), with 30s timeout via `AbortSignal.timeout()` - Added `embedding.baseUrl` for custom endpoints and `embedding.dimensions` for explicit vector sizing on custom models - Split `requestDimensions` (sent to API only when explicitly configured) from `expectedDimensions` (always validated against response) to maintain backward compatibility with providers that reject unknown fields - Removed unused `openai` dependency from `package.json` (~28MB savings at plugin install time) - Comprehensive config validation: type/range checks for dimensions, empty-string rejection for baseUrl, env-var resolution for baseUrl/apiKey - Good test coverage for new validation paths (custom model + dimensions, empty baseUrl, dimension type/range, unknown model without dimensions) <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — clean implementation with proper validation, error handling, and test coverage. - The changes are well-scoped: replace OpenAI SDK with raw fetch for broader compatibility, add new config options with thorough validation, and remove the unused dependency. The follow-up commit addressed all previously flagged issues (timeout, conditional dimensions in request body, unused dep removal). Code paths have good test coverage, error handling is consistent, and the dimension validation split (requestDimensions vs expectedDimensions) correctly preserves backward compatibility. No security concerns — baseUrl is admin-configured, API keys are properly handled, and there are no injection vectors. - No files require special attention. <sub>Last reviewed commit: 3f758e6</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment --> Closes https://github.com/openclaw/openclaw/issues/8118

Most Similar PRs