ai 6.0.152 → 6.0.154

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.154
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [37a378e]
8
+ - @ai-sdk/gateway@3.0.94
9
+
10
+ ## 6.0.153
11
+
12
+ ### Patch Changes
13
+
14
+ - f152133: feat (ai/core): support plain string model IDs in `rerank()` function
15
+
16
+ The `rerank()` function now accepts plain model strings (e.g., `'cohere/rerank-v3.5'`) in addition to `RerankingModel` objects, matching the behavior of `generateText`, `embed`, and other core functions.
17
+
3
18
  ## 6.0.152
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -159,7 +159,7 @@ type LanguageModelResponseMetadata = {
159
159
  /**
160
160
  * Reranking model that is used by the AI SDK.
161
161
  */
162
- type RerankingModel = RerankingModelV3;
162
+ type RerankingModel = string | RerankingModelV3;
163
163
 
164
164
  /**
165
165
  * Provider for language, text embedding, and image models.
@@ -6176,7 +6176,7 @@ interface RerankResult<VALUE> {
6176
6176
  *
6177
6177
  * @returns A result object that contains the reranked documents, the reranked indices, and additional information.
6178
6178
  */
6179
- declare function rerank<VALUE extends JSONObject | string>({ model, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
6179
+ declare function rerank<VALUE extends JSONObject | string>({ model: modelArg, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
6180
6180
  /**
6181
6181
  * The reranking model to use.
6182
6182
  */
package/dist/index.d.ts CHANGED
@@ -159,7 +159,7 @@ type LanguageModelResponseMetadata = {
159
159
  /**
160
160
  * Reranking model that is used by the AI SDK.
161
161
  */
162
- type RerankingModel = RerankingModelV3;
162
+ type RerankingModel = string | RerankingModelV3;
163
163
 
164
164
  /**
165
165
  * Provider for language, text embedding, and image models.
@@ -6176,7 +6176,7 @@ interface RerankResult<VALUE> {
6176
6176
  *
6177
6177
  * @returns A result object that contains the reranked documents, the reranked indices, and additional information.
6178
6178
  */
6179
- declare function rerank<VALUE extends JSONObject | string>({ model, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
6179
+ declare function rerank<VALUE extends JSONObject | string>({ model: modelArg, documents, query, topN, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
6180
6180
  /**
6181
6181
  * The reranking model to use.
6182
6182
  */
package/dist/index.js CHANGED
@@ -968,6 +968,27 @@ function resolveVideoModel(model) {
968
968
  }
969
969
  return model;
970
970
  }
971
+ function resolveRerankingModel(model) {
972
+ if (typeof model === "string") {
973
+ const provider = getGlobalProvider();
974
+ const rerankingModel = provider.rerankingModel;
975
+ if (!rerankingModel) {
976
+ throw new Error(
977
+ 'The default provider does not support reranking models. Please use a RerankingModel object from a provider (e.g., gateway.rerankingModel("model-id")).'
978
+ );
979
+ }
980
+ return rerankingModel(model);
981
+ }
982
+ if (model.specificationVersion !== "v3") {
983
+ const unsupportedModel = model;
984
+ throw new UnsupportedModelVersionError({
985
+ version: unsupportedModel.specificationVersion,
986
+ provider: unsupportedModel.provider,
987
+ modelId: unsupportedModel.modelId
988
+ });
989
+ }
990
+ return model;
991
+ }
971
992
  function getGlobalProvider() {
972
993
  var _a21;
973
994
  return (_a21 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a21 : import_gateway.gateway;
@@ -1231,7 +1252,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
1231
1252
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1232
1253
 
1233
1254
  // src/version.ts
1234
- var VERSION = true ? "6.0.152" : "0.0.0-test";
1255
+ var VERSION = true ? "6.0.154" : "0.0.0-test";
1235
1256
 
1236
1257
  // src/util/download/download.ts
1237
1258
  var download = async ({
@@ -12418,7 +12439,7 @@ var DefaultProviderRegistry = class {
12418
12439
 
12419
12440
  // src/rerank/rerank.ts
12420
12441
  async function rerank({
12421
- model,
12442
+ model: modelArg,
12422
12443
  documents,
12423
12444
  query,
12424
12445
  topN,
@@ -12428,6 +12449,7 @@ async function rerank({
12428
12449
  providerOptions,
12429
12450
  experimental_telemetry: telemetry
12430
12451
  }) {
12452
+ const model = resolveRerankingModel(modelArg);
12431
12453
  if (documents.length === 0) {
12432
12454
  return new DefaultRerankResult({
12433
12455
  originalDocuments: [],