Repository navigation
fix(vertex_ai): send extra_body fields as predict parameters for BGE embedding models - #51662
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
|
bugbot run |
|
@veria-ai |
[Low impact] The PR appears safe to merge, with no new actionable issues found. SummaryBGE embedding requests now put fields from The added unit and integration tests check the outgoing request shape. No new actionable issues were found. kerry-berri accepted the live-provider QA gap because the QA project has no deployed BGE endpoint. The supplied proof instead captures the outgoing request.
Reviews (2) · Last reviewed commit: "Merge branch 'main' into litellm_vertex_..." · Reviewed by Greptile |
| body_params, extra_body = split_extra_body(optional_params) | ||
| vertex_request["parameters"] = ( | ||
| cast( # cast-ok: extra_body carries raw Vertex fields the TypedDict does not list | ||
| EmbeddingParameters, {**extra_body, **body_params} | ||
| ) |
There was a problem hiding this comment.
Required live proof is missing
This changes how BGE receives extra_body fields, but the supplied proof uses a local capture server. The repository requires before/after proxy requests against real providers. Supply qualifying before proof and after proof at 1a561897c14f7d9b70f07dccfe631a1d7b522a74 before merging.
Rule Used: Apply this rule only to PRs that fix LLM translation bugs or add LLM translation features. LLM translation means converting requests, responses, streaming events, tool calls, and errors between the API a caller uses on LiteLLM (any endpoint or SDK fu... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Rebuttal, the QA project has no deployed BGE endpoint, so the proof captures the exact outbound predict body, the only thing this change alters.
There was a problem hiding this comment.
I understand the constraint, and the capture test is useful evidence that LiteLLM emits the intended request body. But because the request is redirected to a local server that fabricates the response, it does not verify that Vertex accepts or applies the flattened autoTruncate parameter. The required proof is a proxy request to the real Vertex API, with before-and-after runs (before on the PR base; after on latest product commit 1a561897c14f7d9b70f07dccfe631a1d7b522a74), including reproducible commands and actual outputs. The lack of a deployed BGE endpoint explains the gap, but does not make the capture-server run equivalent. Please provide that proof or get a maintainer exception to the live-QA requirement.
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
bugbot run |
|
@veria-ai |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 320c5a3. Configure here.
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
Link to Devin session: https://app.devin.ai/sessions/d77a3c28f4084c7cb8c2a6bc18ead1f0
Open in Devin Desktop: https://app.devin.ai/desktop/session/d77a3c28f4084c7cb8c2a6bc18ead1f0?variant=devin
Requested by: @kerry-berri
TLDR
Problem this solves:
extra_bodynested asparameters.extra_bodyHow it solves it:
split_extra_body, like its siblingsextra_bodyfields land directly underparametersUser Flow
Before: a developer who passes a raw Vertex field through
extra_bodyto a BGE embedding model never gets it appliedvertex_ai/bge-small-en-v1.5model and"extra_body": {"autoTruncate": false}"parameters": {"extra_body": {"autoTruncate": false}}, so the field sat under a key the endpoint does not readAfter: the same request delivers the field where the endpoint reads it
"extra_body": {"autoTruncate": false}"parameters": {"autoTruncate": false}, the same shapetext-embedding-005already getsRelevant issues
Follow-up to #51335, which unwrapped
extra_bodyfor the other Vertex text embedding paths.Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
One live proxy per leg, one worker, no Redis and no database, because the change is in the outbound request body only. The Google access token is real, minted from the service account in
VERTEX_AI_DEVIN_SERVICE_ACCOUNT_JSON. The predict endpoint is a local capture server set asapi_base, because the QA project has no deployed BGE endpoint. It prints the body it received and answers with one BGE-shaped prediction.Proxy command, run from the checkout under test
config.yaml (env vars
VERTEXAI_PROJECT,VERTEX_AI_DEVIN_SERVICE_ACCOUNT_JSON)capture.py, started with
python3 capture.py 18801Client command, the same on both legs
Before (7a72c2b)
"embedding":[0.1,0.2,0.3]After (1a56189)
"embedding":[0.1,0.2,0.3]Tests.
tests/integration/providers/test_vertex_embedding_wire.py::test_vertex_bge_embedding_sends_extra_body_fields_as_predict_parametersfails on 7a72c2b with the nested body and passes at the tip (INTEGRATION_WORKERS=2 python tests/integration/run.py providers tests/integration/providers/test_vertex_embedding_wire.py, 5 passed). The unit testtest_vertex_embedding_call_sends_extra_body_fields_as_predict_parametersgained abgecase that fails on main and passes at the tip. The integration file first runs in CI on main after merge.Type
🐛 Bug Fix
Caveats (if any)
Low
Final Attestation
Note
Low Risk
Scoped outbound request shaping for BGE embeddings only; aligns behavior with existing Vertex embedding handlers and is covered by wire and unit tests.
Overview
Vertex BGE embedding requests now flatten
extra_bodyinto top-levelparameters, matching Gecko and other Vertex text embedding paths instead of nesting underparameters.extra_body.VertexBGEConfig.transform_requestadoptssplit_extra_bodyand merges the result intoEmbeddingParametersthe same way astransformation.py. Integration and unit tests assert BGE predict payloads useinstanceswithpromptand bare fields likeautoTruncateonparameters.Reviewed by Cursor Bugbot for commit 320c5a3. Bugbot is set up for automated code reviews on this repo. Configure here.