Skip to content

feat(embeddings): implement /v1/embeddings on the OpenAI-compatible adapter (#40) - #1714

Merged
joelteply merged 1 commit into
canaryfrom
feat/unsloth-embeddings
Jun 21, 2026
Merged

feat(embeddings): implement /v1/embeddings on the OpenAI-compatible adapter (#40)#1714
joelteply merged 1 commit into
canaryfrom
feat/unsloth-embeddings

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Routes continuum's neural recall embeddings through the unsloth gateway's
OpenAI-compatible /v1/embeddings — the first half of #40 ("embeddings → unsloth").

The cognition NeuralEmbeddingProvider already calls adapter.create_embedding(),
but the OpenAICompatibleAdapter inherited the trait's default Err ("does not
support embeddings") — so every neural embed silently degraded to the lexical
fallback. This implements it.

How

  • create_embedding() — POSTs /v1/embeddings using the same base_url /
    Bearer-auth / error-surfacing shape as generate_text. Degrades to Err
    (never panics) on an unreachable endpoint or non-embedding model, so recall
    falls back to the lexical embedder rather than crashing.
  • supports_embeddings now true for "unsloth" as well as "openai".
  • The model is required (no silent default among chat models) — it is the
    embedding-space identity the content-addressed cache keys on.

Pure helpers, TDD'd apart from HTTP I/O:

  • build_embedding_body() — single → string, batch → array
  • parse_embedding_response()orders vectors by the response index
    (the spec doesn't guarantee input order; mis-ordering silently misaligns every
    vector with its source text), errors on missing data instead of fabricating
  • parse_embedding_usage() — usage is observability, defaults to 0, never fails

5 new unit tests.

Scope

This does not yet swap the live default off fastembed or delete the
ort/fastembed embedder — that's the follow-up trim half of #40, which
needs the legacy sync memory/ consumers migrated onto this async path. (Note:
ort itself stays regardless — Piper TTS / Moonshine STT / Silero VAD depend on
it; its retirement is #41.)

🤖 Generated with Claude Code

…dapter (#40)

Routes continuum's neural recall embeddings through the unsloth gateway's
OpenAI-compatible /v1/embeddings — the first half of #40 ("embeddings →
unsloth"). The cognition NeuralEmbeddingProvider already calls
adapter.create_embedding(); until now the OpenAICompatibleAdapter inherited
the trait's default Err ("does not support embeddings"), so every neural
embed silently degraded to the lexical fallback. This implements it.

- create_embedding(): POSTs /v1/embeddings (same base_url / Bearer-auth /
  error-surfacing shape as generate_text). Degrades to Err — never panics —
  on an unreachable endpoint or non-embedding model, so recall falls back to
  the lexical embedder rather than crashing.
- supports_embeddings now true for "unsloth" as well as "openai" (the gateway
  exposes OpenAI-compatible /v1/embeddings).
- The model is required (no silent default among chat models, [[no-fallbacks-ever]])
  — it IS the embedding-space identity the cache keys on.

Pure helpers, TDD'd apart from the HTTP I/O:
- build_embedding_body() — single → string, batch → array
- parse_embedding_response() — orders vectors by the response `index` field
  (the spec does not guarantee input order; mis-ordering silently misaligns
  every vector with its source text), errors on missing data instead of
  fabricating a vector
- parse_embedding_usage() — usage is observability, defaults to 0, never fails

5 new unit tests cover all of the above.

This does NOT yet swap the live default off fastembed or delete the
ort/fastembed embedder — that's the follow-up "trim" half of #40, which
requires migrating the legacy sync memory/ consumers onto this async path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@joelteply
joelteply merged commit 1eb6dd7 into canary Jun 21, 2026
4 checks passed
@joelteply
joelteply deleted the feat/unsloth-embeddings branch June 21, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant