fix(gemini): assign correct indices in batch embedding response - #25656
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
1bd8316 to
2c1a868
Compare
Greptile SummaryThis PR fixes a bug in Confidence Score: 5/5This PR is safe to merge — it's a minimal, well-tested bug fix with no side effects. Single-line correctness fix with a targeted unit test that makes no real network calls. No backwards-incompatible changes, no security implications, and all custom rules are satisfied. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_transformation.py | Correct one-line fix: enumerate replaces hardcoded index=0, assigning proper sequential indices to batch embeddings. |
| tests/litellm/llms/vertex_ai/test_gemini_batch_embeddings.py | New unit test directly calls process_response with mock data, asserting correct sequential indices and value ordering; no real network calls. |
Reviews (2): Last reviewed commit: "fix(gemini): assign correct indices in b..." | Re-trigger Greptile
### Background The Gemini batchEmbedContents response handler hardcoded `index=0` for every embedding in the response. Any consumer relying on the OpenAI-format `index` field to match embeddings back to inputs would silently get wrong associations. ### Changes Use `enumerate` in `process_response` so each embedding gets its positional index instead of 0. ### Test Plan Added unit test asserting sequential indices and correct vector ordering for a 3-element batch response.
2c1a868 to
fbcf870
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
1186544
into
BerriAI:litellm_oss_staging_04_13_2026_p1
### Background The Gemini batchEmbedContents response handler hardcoded `index=0` for every embedding in the response. Any consumer relying on the OpenAI-format `index` field to match embeddings back to inputs would silently get wrong associations. ### Changes Use `enumerate` in `process_response` so each embedding gets its positional index instead of 0. ### Test Plan Added unit test asserting sequential indices and correct vector ordering for a 3-element batch response.
…iAI#25656) ### Background The Gemini batchEmbedContents response handler hardcoded `index=0` for every embedding in the response. Any consumer relying on the OpenAI-format `index` field to match embeddings back to inputs would silently get wrong associations. ### Changes Use `enumerate` in `process_response` so each embedding gets its positional index instead of 0. ### Test Plan Added unit test asserting sequential indices and correct vector ordering for a 3-element batch response.
Relevant issues
The Gemini batchEmbedContents response handler hardcoded
index=0for every embedding in the response. Any consumer relying on the OpenAI-formatindexfield to match embeddings back to inputs would silently get wrong associations.Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
CI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
Added unit test asserting sequential indices and correct vector ordering for a batch response.
Type
🐛 Bug Fix
Changes
Use
enumerateinprocess_responseso each embedding gets its positional index instead of 0.