fix(gemini): apply request-level taskType and title to every batched embedding input - #7884
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe Gemini embedding converter now assigns request-level ChangesGemini Embedding Parameters
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change applies request-level task type and title to every Gemini batched embedding input. No merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
extractTranscriptionUsage builds a new BifrostLLMUsage for pricing and did not copy TranscriptionUsage.Cost, so the provider-cost short circuit in calculateBaseCost never ran for transcription. The request was priced from the datasheet instead, which gives 0 for a per-second priced model whose provider also reports prompt tokens (OpenRouter voxtral). Copy the cost over, as responsesUsageToBifrostUsage already does. Changes: - framework/modelcatalog/datasheet/cost.go - carry the provider cost into the pricing usage - framework/modelcatalog/datasheet/cost_test.go - regression test for transcription and transcription stream responses - framework/changelog.md - changelog entry Fixes #7819
c88fadd to
b338e10
Compare
Merge activity
|

Summary
Two independent bug fixes: (1) Gemini batch embedding requests with a request-level
taskTypeortitle(either as Gemini-native camelCase extra params or first-class snake_case fields) now correctly fan out to everyrequests[]entry of:batchEmbedContentsand no longer leak those keys to the batch top level, where Gemini returns a 400. (2) Transcription cost calculation now carries the provider-reportedusage.costthrough when rebuildingBifrostLLMUsage, so the short-circuit passthrough that chat already uses works correctly for transcription responses.Changes
taskType/titlefan-out ([Bug]: Gemini embeddings:taskType/titleapplied only to the first input of a batched/v1/embeddingsrequest #7812):ToGeminiEmbeddingRequestpreviously assignedbifrostReq.Params.ExtraParamsdirectly to the batch-levelExtraParams, meaning Gemini-native per-entry keys (taskType,title,documentOcr,audioTrackExtraction) were present at the top level of the batch body. Withx-bf-passthrough-extra-paramsenabled, Gemini rejected the request with a 400. The fix clones the extra-params map, strips the per-entry keys from the batch level, andapplyGeminiEmbeddingParamsnow promotestaskTypeandtitlefrom extra params onto the typed fields of each individual entry (honouring first-class fields as the winner). A sentinel listgeminiPerEntryEmbeddingExtraKeysdocuments which keys belong per-entry.extractTranscriptionUsageconstructed a freshBifrostLLMUsage{}without copyingu.Cost, so the provider-reported cost was silently discarded and the datasheet rate was used instead. The fix initialises the struct withCost: u.Cost, matching the existing behaviour for chat and image responses.Type of change
Affected areas
How to test
For the Gemini embedding fix, run the E2E harness against a live Gemini key:
Breaking changes
Related issues
Closes #7812
Closes #7819
Security considerations
None. No auth, secrets, or PII involved.
Checklist
docs/contributing/README.mdand followed the guidelines