Skip to content

feat(mem0-ts): add LM Studio embedder and LLM support#4354

Merged
whysosaket merged 1 commit intomainfrom
feat/mem0-ts-lmstudio-embedder
Mar 17, 2026
Merged

feat(mem0-ts): add LM Studio embedder and LLM support#4354
whysosaket merged 1 commit intomainfrom
feat/mem0-ts-lmstudio-embedder

Conversation

@utkarsh240799
Copy link
Copy Markdown
Contributor

@utkarsh240799 utkarsh240799 commented Mar 16, 2026

Problem

The Python mem0 SDK supports LM Studio as both an embedder and LLM provider, but the TypeScript SDK does not. Users configuring LM Studio via OpenClaw or mem0-ts get Unsupported embedder provider: lmstudio / Unsupported LLM provider: lmstudio errors.

Reported in #4235.

Solution

Add LMStudioEmbedder and LMStudioLLM classes to mem0-ts, matching the Python SDK's feature set:

  • LMStudioEmbedder — Standalone embedder using the OpenAI client with encoding_format: "float" (required because LM Studio doesn't support the OpenAI SDK's default base64 encoding, which produces zero vectors). Includes newline normalization and error wrapping.
  • LMStudioLLM — Extends OpenAILLM with LM Studio defaults (localhost:1234, dummy API key, Meta Llama model). Wraps errors with clear messages.
  • ConfigManager — Normalizes Python SDK snake_case keys (lmstudio_base_urlbaseURL, embedding_dimsembeddingDims) for both embedder and LLM configs. Uses nullish coalescing (??) so existing providers are unaffected.
  • Factory registration"lmstudio" registered in both EmbedderFactory and LLMFactory.
  • Exports and docs — Re-exported from index.ts, documented in OpenClaw README.

Files changed

File Change
mem0-ts/src/oss/src/embeddings/lmstudio.ts New — LMStudioEmbedder
mem0-ts/src/oss/src/llms/lmstudio.ts New — LMStudioLLM
mem0-ts/src/oss/src/utils/factory.ts Register lmstudio in both factories
mem0-ts/src/oss/src/index.ts Re-export both classes
mem0-ts/src/oss/src/config/manager.ts Snake_case normalization for embedder + LLM
openclaw/README.md Document lmstudio as supported provider

Testing

Unit tests (always run)

  • lmstudio-embedder.test.ts (4 tests) — embed with encoding_format: "float", newline normalization, error wrapping, batch embedding
  • lmstudio-llm.test.ts (5 tests) — text response, tool calls, error wrapping, chat response
  • config-manager.test.ts (14 new tests) — snake_case normalization for embedder and LLM, camelCase precedence, full OpenClaw-style config from issue OpenClaw integration doesn’t support lmstudio #4235, mocked Memory E2E flow (factory wiring, dimension auto-detect, search, add)
  • factory.test.ts (2 new tests) — EmbedderFactory.create("lmstudio") and unsupported provider error

Integration tests (require local LM Studio, skipped by default)

  • lmstudio-integration.test.ts (10 tests) — Tested against real LM Studio server with text-embedding-nomic-embed-text-v1.5 (embedder) and qwen2.5-0.5b-instruct (LLM). Enable with LMSTUDIO_INTEGRATION=1.
  • Verified: embedding dimensions (768), newline normalization, batch embeddings, semantic similarity (cosine 0.83 similar vs 0.36 different), chat responses, multi-turn conversation.

Regression

  • All 79 existing tests pass with no changes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

Add LM Studio as a supported provider for both embeddings and LLM in
the TypeScript SDK, bringing it to parity with the Python SDK.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@utkarsh240799 utkarsh240799 force-pushed the feat/mem0-ts-lmstudio-embedder branch from 8ea9c1b to 9aff112 Compare March 17, 2026 12:04
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@whysosaket whysosaket merged commit 336fbce into main Mar 17, 2026
7 checks passed
jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 2026
Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

OpenClaw integration doesn’t support lmstudio

3 participants