FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Provider rejects conforming providers without reranking model su… · vercel/ai@dcf33e8 · GitHub

/ ai Public

Commit dcf33e8

Browse files
authored
fix: Provider rejects conforming providers without reranking model support (#18738)
## Background The exported ai Provider type rejected valid ProviderV3 and ProviderV4 implementations without reranking support, producing TS2322 assignment errors. ## Root Cause Provider declared rerankingModel as required while the V3 and V4 provider contracts declare it optional. The recorded reproduction confirmed this mismatch caused both OpenResponsesProvider and ProviderV3 assignments to fail. ## Summary Made Provider.rerankingModel optional, added a patch changeset, and removed the reproduction-only artifacts. ## Testing Added a type-level regression test confirming ProviderV3 and ProviderV4 are assignable to Provider; verified the test fails when rerankingModel is temporarily required. ## End-to-end Validation - `pnpm -C examples/ai-functions exec tsx src/reproduction/issue-13438-provider-reranking-model.ts` — exited successfully and confirmed both OpenResponsesProvider and ProviderV3 are accepted. ## Related Issues Fixes #13438 Closes #18709 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> Co-authored-by: EurFelux <59059173+EurFelux@users.noreply.github.com>
1 parent 8b77c83 commit dcf33e8

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎.changeset/tidy-pandas-rerank.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
Allow providers without reranking model support to be assigned to `Provider`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { ProviderV3, ProviderV4 } from '@ai-sdk/provider';
2+
import { describe, expectTypeOf, it } from 'vitest';
3+
import type { Provider } from './provider';
4+
5+
describe('Provider', () => {
6+
it('accepts providers with optional reranking model support', () => {
7+
expectTypeOf<ProviderV3>().toMatchTypeOf<Provider>();
8+
expectTypeOf<ProviderV4>().toMatchTypeOf<Provider>();
9+
});
10+
});

‎packages/ai/src/types/provider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ export type Provider = {
5151
*
5252
* @throws {NoSuchModelError} If no such model exists.
5353
*/
54-
rerankingModel(modelId: string): RerankingModel;
54+
rerankingModel?(modelId: string): RerankingModel;
5555
};

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL