Skip to content

feat(embed): support OpenAI-compatible embedding servers (oMLX, vLLM, LM Studio) - #115

Merged
Grivn merged 2 commits into
mnemon-dev:masterfrom
LiTerBo:feat/embed-openai-compatible
Aug 23, 2026
Merged

feat(embed): support OpenAI-compatible embedding servers (oMLX, vLLM, LM Studio)#115
Grivn merged 2 commits into
mnemon-dev:masterfrom
LiTerBo:feat/embed-openai-compatible

Conversation

@LiTerBo

@LiTerBo LiTerBo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The embedding client (internal/memory/embed) currently speaks only the Ollama wire protocol (/api/tags, /api/embed). This PR adds first-class support for OpenAI-compatible embeddings APIs (/v1/models, /v1/embeddings), so local servers such as oMLX, llama.cpp, vLLM and LM Studio can back recall without running Ollama.

Changes

  • MNEMON_EMBED_PROTOCOL=ollama|openai selects the wire protocol. When unset, the protocol is auto-detected: an endpoint whose URL path ends in /v1 is treated as OpenAI-compatible — so an oMLX setup is just MNEMON_EMBED_ENDPOINT=http://127.0.0.1:18000/v1.
  • MNEMON_EMBED_API_KEY attaches a Bearer token for OpenAI-compatible servers (Ollama requires no auth).
  • Available() probes /v1/models on the openai path instead of /api/tags.
  • Embed() parses the {"data":[{"embedding":[...]}]} response shape (the request body is identical for both protocols).
  • All call sites (remember / recall / import / embed) are unchanged — they already go through this single client.
  • Default behavior is fully backward compatible; invalid MNEMON_EMBED_PROTOCOL values warn and fall back to auto-detect.

Verification

  • make test — all packages pass (20/20), including 5 new focused tests (protocol auto-detect + explicit override, auth header on probe & embed, keyless servers, empty-response error).
  • Live end-to-end against a local oMLX server with bge-m3-mlx-8bit (1024 dims): remember reports "embedded": true; a semantic-paraphrase recall query that shares no keywords scores the right insight at 0.498 with vectors vs 0.386 without, and an unrelated-but-similar insight moves 0.064 → 0.425 when the vector signal is available.
  • Fail-open confirmed: when the embedding server is unreachable, embed --status reports ollama_available: false and recall degrades to graph+keyword as before.

The embedding client now speaks the OpenAI-compatible embeddings API in
addition to the Ollama API, so servers such as oMLX, llama.cpp, vLLM and
LM Studio can back recall without running Ollama.

- MNEMON_EMBED_PROTOCOL=ollama|openai selects the wire protocol;
  auto-detected when the endpoint URL path ends in /v1
- MNEMON_EMBED_API_KEY attaches a Bearer token for OpenAI-compatible
  servers (Ollama requires no auth)
- Available() probes /v1/models on the openai path instead of /api/tags
- Embed() parses the {"data":[{"embedding":[...]}]} response shape
- default Ollama behavior is unchanged; verified by make test and a live
  end-to-end run against a local oMLX bge-m3-mlx-8bit server (1024 dims)
@LiTerBo
LiTerBo force-pushed the feat/embed-openai-compatible branch from 36509c5 to ad4def1 Compare August 23, 2026 03:13
Normalize provider URL paths so trailing-slash endpoints work for both OpenAI-compatible servers and Ollama. Keep the legacy status field while adding protocol-neutral CLI output and guidance.

Validation: make test; go build -o mnemon .; GOOS=windows GOARCH=amd64 go build .
@Grivn
Grivn merged commit 2ccd7b4 into mnemon-dev:master Aug 23, 2026
2 checks passed
@LiTerBo
LiTerBo deleted the feat/embed-openai-compatible branch August 23, 2026 13:01
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.

2 participants