fix: send Voyage output_dimension on embedding requests#866
Conversation
8d86478 to
c143cb5
Compare
c143cb5 to
ee90709
Compare
|
Validation update from the refreshed branch:
The focused test includes the wire-level regression that verifies the actual Voyage embedding request body sends output_dimension: 2048. |
|
Thanks @100yenadmin — this catch is real and the fix is the right shape (move dim routing through the SDK-supported Re-landing this as #962 on upstream with your commit preserved verbatim (commit The follow-up fixup on top (commit Closing this in favor of #962. Your authorship stays on the core commit. Appreciate the contribution. |
TL;DR
Fixes Voyage 2048-dimensional embeddings by passing
dimensionsinto the AI SDK, then letting GBrain's existing Voyage fetch shim translate that to Voyage's real wire field,output_dimension. Without this, GBrain can initialize avector(2048)brain but the first Voyage embed request omits the dimension instruction and receives the wrong vector width.What Changed
output_dimensionto SDK-forwardeddimensions.voyageCompatFetchrewrite as the single wire-compatibility point.voyage-4-nanoto the flexible-dimension Voyage model set.output_dimension: 2048.Why This Is The Small Fix
GBrain already has the right architecture: provider dimension knowledge lives in
dims.ts, and Voyage wire differences live in the gateway fetch wrapper. The bug is just thatdims.tswas bypassing the SDK contract by passing Voyage's final wire key too early.This PR keeps the boundary intact:
dims.ts: says "this model needs dimensions"dimensionsoptionvoyageCompatFetch: translates to Voyage'soutput_dimensionNon-Goals
Validation
git diff --checkbun test test/ai/gateway.test.tsCannot find package 'ai'.