Repository navigation
Conversation
OpenAIEmbeddingProvider now unit-normalizes embeddings so non-OpenAI OpenAI-compatible endpoints (e.g. Ark/doubao) satisfy the sqlite distance-to-similarity contract (same as FastEmbed/LiteLLM). Fixes basicmachines-co#1862 Signed-off-by: MbappeWU <MbappeWU@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
Author
|
@CLAassistant check |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenAIEmbeddingProvider.embed_documentsreturned API vectors as-is. Againstapi.openai.comthat is invisible (OpenAI returns unit vectors), but OpenAI-compatible endpoints such as Volcengine Ark / doubao can return unnormalized vectors. The sqlite distance→similarity formula (1 - L²/2) then scores every neighbor near zero, so semantic/hybrid search silently returns no hits.This is the same contract FastEmbed (#1023) and LiteLLM already honor.
Fixes #1862
Changes
OpenAIEmbeddingProvider.embed_documentsafter batches are assembled and before the dimension check (mirrorLiteLLMEmbeddingProvider).[3,4,0]→[0.6,0.8,0]; already-unit and zero vectors unchanged; concurrent batch order still preserved.Test plan
uv run pytest tests/repository/test_openai_provider.py -q→ 35 passeduv run ruff check/ruff format --checkon touched files → cleanNotes
[3,4,0]), then the full file suite passed.