Repository navigation
fix(embedding): forward providerOptions.openrouter in embed/embedMany - #632
Merged
Merged
Conversation
Merge provider routing preferences from settings, extraBody and providerOptions (later wins), matching chat/completion. Related to #616.
5 tasks done
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.
Description
Related to #616.
The embedding model ignored call-time
providerOptions.openrouter.doEmbedbuilt the request body fromsettingsandextraBodyonly, soembed/embedManycalls likeproviderOptions: { openrouter: { provider: { only: ['x'] } } }sent noproviderat all. Chat and completion already forward these options.Changes:
doEmbednow takesEmbeddingModelV4CallOptions, readsproviderOptions.openrouter, and spreads it into the body aftersettings/extraBody, the same way chat and completion do. Any field the/embeddingsendpoint accepts (provider,user,dimensions,input_type,session_id,trace, ...) passes through.providerrouting is shallow merged with precedencesettings.provider < config.extraBody.provider < settings.extraBody.provider < providerOptions.openrouter.provider. Null, array and primitive values are ignored. One behavior change: anextraBody.providerused to replacesettings.provider; now the two merge.Relationship to #628
#628 (still open) adds a shared
src/utils/merge-provider-routing.tshelper with the same semantics for chat, completion and image. This PR doesn't depend on #628 and doesn't touch any of its files. It uses a small localmergeProviderRoutinginsrc/embedding/index.ts, with aTODO(#628)to swap in the shared helper once that PR merges. The two can merge in either order without conflicts.Tests
src/embedding/index.test.ts) run realembed/embedManyagainst a mocked fetch and check the request body for: runtime-onlyprovider, merging withsettings.provider, the full precedence chain, ignoring a null runtimeprovider, passthrough of other options (user,dimensions,input_type,session_id), an unchanged body when noproviderOptionsare given, andproviderleft out when nothing sets it. 6 of these fail onmain.e2e/issues/issue-616-embedding-provider-options.test.ts: a live run against OpenRouter passes here. Onmain, 3 of its 4 cases fail: an unknownprovider.onlyisn't rejected, anddimensions: 256is ignored.Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset file