ai 3.1.34 → 3.1.36
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.d.mts +77 -37
- package/dist/index.d.ts +77 -37
- package/dist/index.js +102 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/rsc/dist/rsc-server.mjs +42 -0
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.36",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"sideEffects": false,
|
6
6
|
"main": "./dist/index.js",
|
@@ -58,12 +58,12 @@
|
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
60
|
"@ai-sdk/provider": "0.0.10",
|
61
|
-
"@ai-sdk/provider-utils": "0.0.
|
62
|
-
"@ai-sdk/react": "0.0.
|
63
|
-
"@ai-sdk/solid": "0.0.
|
64
|
-
"@ai-sdk/svelte": "0.0.
|
65
|
-
"@ai-sdk/ui-utils": "0.0.
|
66
|
-
"@ai-sdk/vue": "0.0.
|
61
|
+
"@ai-sdk/provider-utils": "0.0.14",
|
62
|
+
"@ai-sdk/react": "0.0.2",
|
63
|
+
"@ai-sdk/solid": "0.0.2",
|
64
|
+
"@ai-sdk/svelte": "0.0.2",
|
65
|
+
"@ai-sdk/ui-utils": "0.0.2",
|
66
|
+
"@ai-sdk/vue": "0.0.2",
|
67
67
|
"eventsource-parser": "1.1.2",
|
68
68
|
"jsondiffpatch": "0.6.0",
|
69
69
|
"json-schema": "0.4.0",
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -277,6 +277,7 @@ var InvalidMessageRoleError = class extends Error {
|
|
277
277
|
};
|
278
278
|
|
279
279
|
// core/prompt/convert-to-language-model-prompt.ts
|
280
|
+
import { getErrorMessage as getErrorMessage2 } from "@ai-sdk/provider-utils";
|
280
281
|
function convertToLanguageModelPrompt(prompt) {
|
281
282
|
const languageModelMessages = [];
|
282
283
|
if (prompt.system != null) {
|
@@ -334,6 +335,47 @@ function convertToLanguageModelMessage(message) {
|
|
334
335
|
mimeType: part.mimeType
|
335
336
|
};
|
336
337
|
}
|
338
|
+
if (typeof part.image === "string") {
|
339
|
+
try {
|
340
|
+
const url = new URL(part.image);
|
341
|
+
switch (url.protocol) {
|
342
|
+
case "http:":
|
343
|
+
case "https:": {
|
344
|
+
return {
|
345
|
+
type: "image",
|
346
|
+
image: url,
|
347
|
+
mimeType: part.mimeType
|
348
|
+
};
|
349
|
+
}
|
350
|
+
case "data:": {
|
351
|
+
try {
|
352
|
+
const [header, base64Content] = part.image.split(",");
|
353
|
+
const mimeType = header.split(";")[0].split(":")[1];
|
354
|
+
if (mimeType == null || base64Content == null) {
|
355
|
+
throw new Error("Invalid data URL format");
|
356
|
+
}
|
357
|
+
return {
|
358
|
+
type: "image",
|
359
|
+
image: convertDataContentToUint8Array(base64Content),
|
360
|
+
mimeType
|
361
|
+
};
|
362
|
+
} catch (error) {
|
363
|
+
throw new Error(
|
364
|
+
`Error processing data URL: ${getErrorMessage2(
|
365
|
+
message
|
366
|
+
)}`
|
367
|
+
);
|
368
|
+
}
|
369
|
+
}
|
370
|
+
default: {
|
371
|
+
throw new Error(
|
372
|
+
`Unsupported URL protocol: ${url.protocol}`
|
373
|
+
);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
} catch (_ignored) {
|
377
|
+
}
|
378
|
+
}
|
337
379
|
const imageUint8 = convertDataContentToUint8Array(part.image);
|
338
380
|
return {
|
339
381
|
type: "image",
|