ai 6.0.151 → 6.0.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -153,7 +153,7 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
153
153
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
154
154
 
155
155
  // src/version.ts
156
- var VERSION = true ? "6.0.151" : "0.0.0-test";
156
+ var VERSION = true ? "6.0.153" : "0.0.0-test";
157
157
 
158
158
  // src/util/download/download.ts
159
159
  var download = async ({
@@ -133,7 +133,7 @@ import {
133
133
  } from "@ai-sdk/provider-utils";
134
134
 
135
135
  // src/version.ts
136
- var VERSION = true ? "6.0.151" : "0.0.0-test";
136
+ var VERSION = true ? "6.0.153" : "0.0.0-test";
137
137
 
138
138
  // src/util/download/download.ts
139
139
  var download = async ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.151",
3
+ "version": "6.0.153",
4
4
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -5,6 +5,7 @@ import {
5
5
  ImageModelV3,
6
6
  LanguageModelV3,
7
7
  ProviderV3,
8
+ RerankingModelV3,
8
9
  SpeechModelV3,
9
10
  TranscriptionModelV3,
10
11
  } from '@ai-sdk/provider';
@@ -19,6 +20,7 @@ import { asLanguageModelV3 } from './as-language-model-v3';
19
20
  import { asSpeechModelV3 } from './as-speech-model-v3';
20
21
  import { asTranscriptionModelV3 } from './as-transcription-model-v3';
21
22
  import { ImageModel } from '../types/image-model';
23
+ import { RerankingModel } from '../types/reranking-model';
22
24
  import { VideoModel } from '../types/video-model';
23
25
 
24
26
  export function resolveLanguageModel(model: LanguageModel): LanguageModelV3 {
@@ -154,6 +156,33 @@ export function resolveVideoModel(
154
156
  return model;
155
157
  }
156
158
 
159
+ export function resolveRerankingModel(model: RerankingModel): RerankingModelV3 {
160
+ if (typeof model === 'string') {
161
+ const provider = getGlobalProvider();
162
+ const rerankingModel = provider.rerankingModel;
163
+
164
+ if (!rerankingModel) {
165
+ throw new Error(
166
+ 'The default provider does not support reranking models. ' +
167
+ 'Please use a RerankingModel object from a provider (e.g., gateway.rerankingModel("model-id")).',
168
+ );
169
+ }
170
+
171
+ return rerankingModel(model);
172
+ }
173
+
174
+ if (model.specificationVersion !== 'v3') {
175
+ const unsupportedModel: any = model;
176
+ throw new UnsupportedModelVersionError({
177
+ version: unsupportedModel.specificationVersion,
178
+ provider: unsupportedModel.provider,
179
+ modelId: unsupportedModel.modelId,
180
+ });
181
+ }
182
+
183
+ return model;
184
+ }
185
+
157
186
  function getGlobalProvider(): ProviderV3 {
158
187
  return globalThis.AI_SDK_DEFAULT_PROVIDER ?? gateway;
159
188
  }
@@ -7,6 +7,7 @@ import { getTracer } from '../telemetry/get-tracer';
7
7
  import { recordSpan } from '../telemetry/record-span';
8
8
  import { selectTelemetryAttributes } from '../telemetry/select-telemetry-attributes';
9
9
  import { TelemetrySettings } from '../telemetry/telemetry-settings';
10
+ import { resolveRerankingModel } from '../model/resolve-model';
10
11
  import { RerankingModel } from '../types';
11
12
  import { RerankResult } from './rerank-result';
12
13
  import { logWarnings } from '../logger/log-warnings';
@@ -28,7 +29,7 @@ import { logWarnings } from '../logger/log-warnings';
28
29
  * @returns A result object that contains the reranked documents, the reranked indices, and additional information.
29
30
  */
30
31
  export async function rerank<VALUE extends JSONObject | string>({
31
- model,
32
+ model: modelArg,
32
33
  documents,
33
34
  query,
34
35
  topN,
@@ -88,6 +89,8 @@ export async function rerank<VALUE extends JSONObject | string>({
88
89
  */
89
90
  providerOptions?: ProviderOptions;
90
91
  }): Promise<RerankResult<VALUE>> {
92
+ const model = resolveRerankingModel(modelArg);
93
+
91
94
  if (documents.length === 0) {
92
95
  return new DefaultRerankResult({
93
96
  originalDocuments: [],
@@ -3,4 +3,4 @@ import { RerankingModelV3 } from '@ai-sdk/provider';
3
3
  /**
4
4
  * Reranking model that is used by the AI SDK.
5
5
  */
6
- export type RerankingModel = RerankingModelV3;
6
+ export type RerankingModel = string | RerankingModelV3;