ai 3.3.32 → 3.3.34

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,21 @@
1
1
  # ai
2
2
 
3
+ ## 3.3.34
4
+
5
+ ### Patch Changes
6
+
7
+ - a0403d6: feat (react): support sending attachments using append
8
+ - 678449a: feat (ai/core): export test helpers
9
+ - ff22fac: fix (ai/rsc): streamUI onFinish is called when tool calls have finished
10
+ - Updated dependencies [a0403d6]
11
+ - @ai-sdk/react@0.0.56
12
+
13
+ ## 3.3.33
14
+
15
+ ### Patch Changes
16
+
17
+ - cbddc83: fix (ai/core): filter out empty text parts
18
+
3
19
  ## 3.3.32
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Schema, DeepPartial, ToolInvocation, Attachment, JSONValue as JSONValue$1, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
2
- export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseStreamPart, processDataProtocolResponse, readDataStream } from '@ai-sdk/ui-utils';
2
+ export { AssistantMessage, AssistantStatus, Attachment, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseStreamPart, processDataProtocolResponse, readDataStream } from '@ai-sdk/ui-utils';
3
3
  import { AttributeValue } from '@opentelemetry/api';
4
4
  import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1ProviderMetadata, JSONValue, LanguageModelV1CallOptions, NoSuchModelError, AISDKError } from '@ai-sdk/provider';
5
5
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LanguageModelV1, LanguageModelV1CallOptions, LanguageModelV1Prompt, LanguageModelV1StreamPart, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Schema, DeepPartial, ToolInvocation, Attachment, JSONValue as JSONValue$1, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
2
- export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseStreamPart, processDataProtocolResponse, readDataStream } from '@ai-sdk/ui-utils';
2
+ export { AssistantMessage, AssistantStatus, Attachment, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, Schema, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, jsonSchema, parseStreamPart, processDataProtocolResponse, readDataStream } from '@ai-sdk/ui-utils';
3
3
  import { AttributeValue } from '@opentelemetry/api';
4
4
  import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1ProviderMetadata, JSONValue, LanguageModelV1CallOptions, NoSuchModelError, AISDKError } from '@ai-sdk/provider';
5
5
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LanguageModelV1, LanguageModelV1CallOptions, LanguageModelV1Prompt, LanguageModelV1StreamPart, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
package/dist/index.js CHANGED
@@ -945,100 +945,98 @@ function convertToLanguageModelMessage(message, downloadedImages) {
945
945
  }
946
946
  return {
947
947
  role: "user",
948
- content: message.content.map(
949
- (part) => {
950
- var _a11, _b, _c;
951
- switch (part.type) {
952
- case "text": {
953
- return {
954
- type: "text",
955
- text: part.text,
956
- providerMetadata: part.experimental_providerMetadata
957
- };
958
- }
959
- case "image": {
960
- if (part.image instanceof URL) {
961
- if (downloadedImages == null) {
962
- return {
963
- type: "image",
964
- image: part.image,
965
- mimeType: part.mimeType,
966
- providerMetadata: part.experimental_providerMetadata
967
- };
968
- } else {
969
- const downloadedImage = downloadedImages[part.image.toString()];
970
- return {
971
- type: "image",
972
- image: downloadedImage.data,
973
- mimeType: (_a11 = part.mimeType) != null ? _a11 : downloadedImage.mimeType,
974
- providerMetadata: part.experimental_providerMetadata
975
- };
976
- }
948
+ content: message.content.map((part) => {
949
+ var _a11, _b, _c;
950
+ switch (part.type) {
951
+ case "text": {
952
+ return {
953
+ type: "text",
954
+ text: part.text,
955
+ providerMetadata: part.experimental_providerMetadata
956
+ };
957
+ }
958
+ case "image": {
959
+ if (part.image instanceof URL) {
960
+ if (downloadedImages == null) {
961
+ return {
962
+ type: "image",
963
+ image: part.image,
964
+ mimeType: part.mimeType,
965
+ providerMetadata: part.experimental_providerMetadata
966
+ };
967
+ } else {
968
+ const downloadedImage = downloadedImages[part.image.toString()];
969
+ return {
970
+ type: "image",
971
+ image: downloadedImage.data,
972
+ mimeType: (_a11 = part.mimeType) != null ? _a11 : downloadedImage.mimeType,
973
+ providerMetadata: part.experimental_providerMetadata
974
+ };
977
975
  }
978
- if (typeof part.image === "string") {
979
- try {
980
- const url = new URL(part.image);
981
- switch (url.protocol) {
982
- case "http:":
983
- case "https:": {
984
- if (downloadedImages == null) {
985
- return {
986
- type: "image",
987
- image: url,
988
- mimeType: part.mimeType,
989
- providerMetadata: part.experimental_providerMetadata
990
- };
991
- } else {
992
- const downloadedImage = downloadedImages[part.image];
993
- return {
994
- type: "image",
995
- image: downloadedImage.data,
996
- mimeType: (_b = part.mimeType) != null ? _b : downloadedImage.mimeType,
997
- providerMetadata: part.experimental_providerMetadata
998
- };
999
- }
976
+ }
977
+ if (typeof part.image === "string") {
978
+ try {
979
+ const url = new URL(part.image);
980
+ switch (url.protocol) {
981
+ case "http:":
982
+ case "https:": {
983
+ if (downloadedImages == null) {
984
+ return {
985
+ type: "image",
986
+ image: url,
987
+ mimeType: part.mimeType,
988
+ providerMetadata: part.experimental_providerMetadata
989
+ };
990
+ } else {
991
+ const downloadedImage = downloadedImages[part.image];
992
+ return {
993
+ type: "image",
994
+ image: downloadedImage.data,
995
+ mimeType: (_b = part.mimeType) != null ? _b : downloadedImage.mimeType,
996
+ providerMetadata: part.experimental_providerMetadata
997
+ };
1000
998
  }
1001
- case "data:": {
1002
- try {
1003
- const [header, base64Content] = part.image.split(",");
1004
- const mimeType = header.split(";")[0].split(":")[1];
1005
- if (mimeType == null || base64Content == null) {
1006
- throw new Error("Invalid data URL format");
1007
- }
1008
- return {
1009
- type: "image",
1010
- image: convertDataContentToUint8Array(base64Content),
1011
- mimeType,
1012
- providerMetadata: part.experimental_providerMetadata
1013
- };
1014
- } catch (error) {
1015
- throw new Error(
1016
- `Error processing data URL: ${(0, import_provider_utils3.getErrorMessage)(
1017
- message
1018
- )}`
1019
- );
999
+ }
1000
+ case "data:": {
1001
+ try {
1002
+ const [header, base64Content] = part.image.split(",");
1003
+ const mimeType = header.split(";")[0].split(":")[1];
1004
+ if (mimeType == null || base64Content == null) {
1005
+ throw new Error("Invalid data URL format");
1020
1006
  }
1021
- }
1022
- default: {
1007
+ return {
1008
+ type: "image",
1009
+ image: convertDataContentToUint8Array(base64Content),
1010
+ mimeType,
1011
+ providerMetadata: part.experimental_providerMetadata
1012
+ };
1013
+ } catch (error) {
1023
1014
  throw new Error(
1024
- `Unsupported URL protocol: ${url.protocol}`
1015
+ `Error processing data URL: ${(0, import_provider_utils3.getErrorMessage)(
1016
+ message
1017
+ )}`
1025
1018
  );
1026
1019
  }
1027
1020
  }
1028
- } catch (_ignored) {
1021
+ default: {
1022
+ throw new Error(
1023
+ `Unsupported URL protocol: ${url.protocol}`
1024
+ );
1025
+ }
1029
1026
  }
1027
+ } catch (_ignored) {
1030
1028
  }
1031
- const imageUint8 = convertDataContentToUint8Array(part.image);
1032
- return {
1033
- type: "image",
1034
- image: imageUint8,
1035
- mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
1036
- providerMetadata: part.experimental_providerMetadata
1037
- };
1038
1029
  }
1030
+ const imageUint8 = convertDataContentToUint8Array(part.image);
1031
+ return {
1032
+ type: "image",
1033
+ image: imageUint8,
1034
+ mimeType: (_c = part.mimeType) != null ? _c : detectImageMimeType(imageUint8),
1035
+ providerMetadata: part.experimental_providerMetadata
1036
+ };
1039
1037
  }
1040
1038
  }
1041
- ),
1039
+ }).filter((part) => part.type !== "text" || part.text !== ""),
1042
1040
  providerMetadata: message.experimental_providerMetadata
1043
1041
  };
1044
1042
  }