fix: tolerate unknown gateway model types in /api/models#736
Open
8dazo wants to merge 1 commit into
Open
Conversation
|
@8dazo is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@willsather @nicoalbanese could please verify it. |
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.
fixes #735: Reranking Models And
/api/modelsWhat happened
The upstream AI Gateway
/configresponse included a model entry like:{ "id": "cohere/rerank-v3.5", "name": "Cohere Rerank 3.5", "description": "Rerank 3.5 efficiently finds the most relevant business data to answer a user question...", "modelType": "reranking", "tags": [], "specification": { "specificationVersion": "v3", "provider": "bedrock", "modelId": "cohere/rerank-v3.5", "type": "reranking" }, "pricing": { "input": "0", "output": "0" } }Why it failed
The current SDK validation for
gateway.getAvailableModels()only accepts thesemodelTypevalues:embeddingimagelanguagevideoBecause the Gateway payload included
modelType: "reranking", the SDK rejected the entire response during validation.That meant
/api/modelsfailed before our code could filter the response down to language models, so the route returned500.What this means for reranking models
Reranking models are not supported by this endpoint today.
They should not be returned by
/api/models, because this route is used for language-model selection in the app. The correct behavior is:rerankingFix summary
We added a fallback path in
apps/web/lib/models-with-context.tsso that when Gateway metadata validation fails, the app:languagemodel entries/api/modelssuccessfullyResult
After the fix:
/api/modelsreturns200instead of500