ai 7.0.111 → 7.0.112
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 +15 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +31 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +21 -4
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-core/40-middleware.mdx +92 -7
- package/docs/06-advanced/02-stopping-streams.mdx +8 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +3 -3
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +9 -3
- package/package.json +12 -12
- package/src/generate-text/prune-messages.ts +3 -1
- package/src/prompt/convert-to-language-model-prompt.ts +12 -2
- package/src/prompt/file-part-data.ts +11 -1
- package/src/ui/validate-ui-messages.ts +2 -2
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +5 -3
- package/src/ui-message-stream/ui-message-stream-on-end-callback.ts +8 -0
- package/src/ui-message-stream/ui-message-stream-outcome.ts +4 -0
package/dist/internal/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "@ai-sdk/provider-utils";
|
|
92
92
|
|
|
93
93
|
// src/version.ts
|
|
94
|
-
var VERSION = true ? "7.0.
|
|
94
|
+
var VERSION = true ? "7.0.112" : "0.0.0-test";
|
|
95
95
|
|
|
96
96
|
// src/util/download/download.ts
|
|
97
97
|
var download = async ({
|
|
@@ -241,6 +241,13 @@ function convertUrlToFilePartData(url) {
|
|
|
241
241
|
}
|
|
242
242
|
return { data: { type: "url", url }, mediaType: void 0 };
|
|
243
243
|
}
|
|
244
|
+
function convertUrlStringToFilePartData(content) {
|
|
245
|
+
const result = convertUrlToFilePartData(new URL(content));
|
|
246
|
+
if (result.data.type === "url" && result.data.url.toString() !== content) {
|
|
247
|
+
result.data.originalUrl = content;
|
|
248
|
+
}
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
244
251
|
function convertInlineDataToFilePartData(content) {
|
|
245
252
|
if (content instanceof Uint8Array) {
|
|
246
253
|
return { data: { type: "data", data: content }, mediaType: void 0 };
|
|
@@ -292,7 +299,7 @@ function convertToLanguageModelV4FilePart(content) {
|
|
|
292
299
|
}
|
|
293
300
|
if (typeof content === "string") {
|
|
294
301
|
try {
|
|
295
|
-
return
|
|
302
|
+
return convertUrlStringToFilePartData(content);
|
|
296
303
|
} catch (e) {
|
|
297
304
|
return convertInlineDataToFilePartData(content);
|
|
298
305
|
}
|
|
@@ -893,6 +900,7 @@ function mapToolResultOutput({
|
|
|
893
900
|
}
|
|
894
901
|
case "file-url": {
|
|
895
902
|
const mediaType = (_a12 = item.mediaType) != null ? _a12 : getMediaTypeFromUrl(item.url);
|
|
903
|
+
const url = new URL(item.url);
|
|
896
904
|
let message = `The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;
|
|
897
905
|
if (!item.mediaType) {
|
|
898
906
|
const inferenceSuffix = mediaType === "application/octet-stream" ? `Unable to infer media type from URL. Defaulting to 'application/octet-stream'.` : `Inferred media type '${mediaType}' from URL.`;
|
|
@@ -905,7 +913,11 @@ function mapToolResultOutput({
|
|
|
905
913
|
});
|
|
906
914
|
return {
|
|
907
915
|
type: "file",
|
|
908
|
-
data: {
|
|
916
|
+
data: {
|
|
917
|
+
type: "url",
|
|
918
|
+
url,
|
|
919
|
+
...url.toString() !== item.url ? { originalUrl: item.url } : {}
|
|
920
|
+
},
|
|
909
921
|
mediaType,
|
|
910
922
|
providerOptions: item.providerOptions
|
|
911
923
|
};
|
|
@@ -961,6 +973,7 @@ function mapToolResultOutput({
|
|
|
961
973
|
};
|
|
962
974
|
}
|
|
963
975
|
case "image-url": {
|
|
976
|
+
const url = new URL(item.url);
|
|
964
977
|
warnings.push({
|
|
965
978
|
type: "deprecated",
|
|
966
979
|
setting: '"tool-result" content of type "image-url"',
|
|
@@ -968,7 +981,11 @@ function mapToolResultOutput({
|
|
|
968
981
|
});
|
|
969
982
|
return {
|
|
970
983
|
type: "file",
|
|
971
|
-
data: {
|
|
984
|
+
data: {
|
|
985
|
+
type: "url",
|
|
986
|
+
url,
|
|
987
|
+
...url.toString() !== item.url ? { originalUrl: item.url } : {}
|
|
988
|
+
},
|
|
972
989
|
mediaType: "image",
|
|
973
990
|
providerOptions: item.providerOptions
|
|
974
991
|
};
|