ai 6.0.283 → 6.0.284

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/dist/index.mjs CHANGED
@@ -1224,7 +1224,7 @@ import {
1224
1224
  } from "@ai-sdk/provider-utils";
1225
1225
 
1226
1226
  // src/version.ts
1227
- var VERSION = true ? "6.0.283" : "0.0.0-test";
1227
+ var VERSION = true ? "6.0.284" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -10293,6 +10293,12 @@ async function embed({
10293
10293
  }
10294
10294
  })
10295
10295
  );
10296
+ if (embedding2 == null) {
10297
+ throw new InvalidResponseDataError({
10298
+ data: modelResponse.embeddings,
10299
+ message: "No embedding generated."
10300
+ });
10301
+ }
10296
10302
  return {
10297
10303
  embedding: embedding2,
10298
10304
  usage: usage2,
@@ -13756,6 +13762,9 @@ var DefaultProviderRegistry = class {
13756
13762
  };
13757
13763
 
13758
13764
  // src/rerank/rerank.ts
13765
+ import {
13766
+ InvalidResponseDataError as InvalidResponseDataError2
13767
+ } from "@ai-sdk/provider";
13759
13768
  async function rerank({
13760
13769
  model: modelArg,
13761
13770
  documents,
@@ -13854,6 +13863,7 @@ async function rerank({
13854
13863
  }
13855
13864
  })
13856
13865
  );
13866
+ validateRankingIndices({ ranking, documents });
13857
13867
  logWarnings({
13858
13868
  warnings: warnings != null ? warnings : [],
13859
13869
  provider: model.provider,
@@ -13878,6 +13888,19 @@ async function rerank({
13878
13888
  }
13879
13889
  });
13880
13890
  }
13891
+ function validateRankingIndices({
13892
+ ranking,
13893
+ documents
13894
+ }) {
13895
+ for (const { index } of ranking) {
13896
+ if (!Number.isInteger(index) || index < 0 || index >= documents.length) {
13897
+ throw new InvalidResponseDataError2({
13898
+ data: ranking,
13899
+ message: `Invalid ranking index ${index}. Expected an integer between 0 and ${documents.length - 1}.`
13900
+ });
13901
+ }
13902
+ }
13903
+ }
13881
13904
  var DefaultRerankResult = class {
13882
13905
  constructor(options) {
13883
13906
  this.originalDocuments = options.originalDocuments;