ai 4.1.49 → 4.1.51

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
@@ -1256,12 +1256,12 @@ async function downloadAssets(messages, downloadImplementation, modelSupportsIma
1256
1256
  );
1257
1257
  }
1258
1258
  function convertPartToLanguageModelPart(part, downloadedAssets) {
1259
- var _a16;
1259
+ var _a16, _b, _c, _d;
1260
1260
  if (part.type === "text") {
1261
1261
  return {
1262
1262
  type: "text",
1263
1263
  text: part.text,
1264
- providerMetadata: part.experimental_providerMetadata
1264
+ providerMetadata: (_a16 = part.providerOptions) != null ? _a16 : part.experimental_providerMetadata
1265
1265
  };
1266
1266
  }
1267
1267
  let mimeType = part.mimeType;
@@ -1309,13 +1309,13 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
1309
1309
  switch (type) {
1310
1310
  case "image": {
1311
1311
  if (normalizedData instanceof Uint8Array) {
1312
- mimeType = (_a16 = detectImageMimeType(normalizedData)) != null ? _a16 : mimeType;
1312
+ mimeType = (_b = detectImageMimeType(normalizedData)) != null ? _b : mimeType;
1313
1313
  }
1314
1314
  return {
1315
1315
  type: "image",
1316
1316
  image: normalizedData,
1317
1317
  mimeType,
1318
- providerMetadata: part.experimental_providerMetadata
1318
+ providerMetadata: (_c = part.providerOptions) != null ? _c : part.experimental_providerMetadata
1319
1319
  };
1320
1320
  }
1321
1321
  case "file": {
@@ -1326,7 +1326,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
1326
1326
  type: "file",
1327
1327
  data: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,
1328
1328
  mimeType,
1329
- providerMetadata: part.experimental_providerMetadata
1329
+ providerMetadata: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata
1330
1330
  };
1331
1331
  }
1332
1332
  }
@@ -5723,7 +5723,8 @@ var DefaultStreamTextResult = class {
5723
5723
  // mask error messages for safety by default
5724
5724
  sendUsage = true,
5725
5725
  sendReasoning = false,
5726
- sendSources = false
5726
+ sendSources = false,
5727
+ experimental_sendFinish = true
5727
5728
  }) {
5728
5729
  return this.fullStream.pipeThrough(
5729
5730
  new TransformStream({
@@ -5835,15 +5836,17 @@ var DefaultStreamTextResult = class {
5835
5836
  break;
5836
5837
  }
5837
5838
  case "finish": {
5838
- controller.enqueue(
5839
- formatDataStreamPart2("finish_message", {
5840
- finishReason: chunk.finishReason,
5841
- usage: sendUsage ? {
5842
- promptTokens: chunk.usage.promptTokens,
5843
- completionTokens: chunk.usage.completionTokens
5844
- } : void 0
5845
- })
5846
- );
5839
+ if (experimental_sendFinish) {
5840
+ controller.enqueue(
5841
+ formatDataStreamPart2("finish_message", {
5842
+ finishReason: chunk.finishReason,
5843
+ usage: sendUsage ? {
5844
+ promptTokens: chunk.usage.promptTokens,
5845
+ completionTokens: chunk.usage.completionTokens
5846
+ } : void 0
5847
+ })
5848
+ );
5849
+ }
5847
5850
  break;
5848
5851
  }
5849
5852
  default: {
@@ -5863,7 +5866,8 @@ var DefaultStreamTextResult = class {
5863
5866
  getErrorMessage: getErrorMessage5,
5864
5867
  sendUsage,
5865
5868
  sendReasoning,
5866
- sendSources
5869
+ sendSources,
5870
+ experimental_sendFinish
5867
5871
  } = {}) {
5868
5872
  writeToServerResponse({
5869
5873
  response,
@@ -5878,7 +5882,8 @@ var DefaultStreamTextResult = class {
5878
5882
  getErrorMessage: getErrorMessage5,
5879
5883
  sendUsage,
5880
5884
  sendReasoning,
5881
- sendSources
5885
+ sendSources,
5886
+ experimental_sendFinish
5882
5887
  })
5883
5888
  });
5884
5889
  }
@@ -5899,7 +5904,8 @@ var DefaultStreamTextResult = class {
5899
5904
  getErrorMessage: options == null ? void 0 : options.getErrorMessage,
5900
5905
  sendUsage: options == null ? void 0 : options.sendUsage,
5901
5906
  sendReasoning: options == null ? void 0 : options.sendReasoning,
5902
- sendSources: options == null ? void 0 : options.sendSources
5907
+ sendSources: options == null ? void 0 : options.sendSources,
5908
+ experimental_sendFinish: options == null ? void 0 : options.experimental_sendFinish
5903
5909
  }).pipeThrough(new TextEncoderStream());
5904
5910
  return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
5905
5911
  }
@@ -5909,7 +5915,8 @@ var DefaultStreamTextResult = class {
5909
5915
  getErrorMessage: writer.onError,
5910
5916
  sendUsage: options == null ? void 0 : options.sendUsage,
5911
5917
  sendReasoning: options == null ? void 0 : options.sendReasoning,
5912
- sendSources: options == null ? void 0 : options.sendSources
5918
+ sendSources: options == null ? void 0 : options.sendSources,
5919
+ experimental_sendFinish: options == null ? void 0 : options.experimental_sendFinish
5913
5920
  })
5914
5921
  );
5915
5922
  }
@@ -5921,7 +5928,8 @@ var DefaultStreamTextResult = class {
5921
5928
  getErrorMessage: getErrorMessage5,
5922
5929
  sendUsage,
5923
5930
  sendReasoning,
5924
- sendSources
5931
+ sendSources,
5932
+ experimental_sendFinish
5925
5933
  } = {}) {
5926
5934
  return new Response(
5927
5935
  this.toDataStream({
@@ -5929,7 +5937,8 @@ var DefaultStreamTextResult = class {
5929
5937
  getErrorMessage: getErrorMessage5,
5930
5938
  sendUsage,
5931
5939
  sendReasoning,
5932
- sendSources
5940
+ sendSources,
5941
+ experimental_sendFinish
5933
5942
  }),
5934
5943
  {
5935
5944
  status,