ai 3.0.16 → 3.0.18
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/anthropic/dist/index.d.mts +371 -0
- package/anthropic/dist/index.d.ts +371 -0
- package/anthropic/dist/index.js +946 -0
- package/anthropic/dist/index.js.map +1 -0
- package/anthropic/dist/index.mjs +910 -0
- package/anthropic/dist/index.mjs.map +1 -0
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -2
- package/dist/index.mjs.map +1 -1
- package/google/dist/index.d.mts +365 -0
- package/google/dist/index.d.ts +365 -0
- package/google/dist/index.js +950 -0
- package/google/dist/index.js.map +1 -0
- package/google/dist/index.mjs +914 -0
- package/google/dist/index.mjs.map +1 -0
- package/mistral/dist/index.js +6 -6
- package/mistral/dist/index.js.map +1 -1
- package/mistral/dist/index.mjs +6 -6
- package/mistral/dist/index.mjs.map +1 -1
- package/openai/dist/index.js +1 -2
- package/openai/dist/index.js.map +1 -1
- package/openai/dist/index.mjs +1 -2
- package/openai/dist/index.mjs.map +1 -1
- package/package.json +18 -2
- package/spec/dist/index.js +1 -2
- package/spec/dist/index.js.map +1 -1
- package/spec/dist/index.mjs +1 -2
- package/spec/dist/index.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -351,6 +351,22 @@ function calculateTokenUsage(usage) {
|
|
351
351
|
};
|
352
352
|
}
|
353
353
|
|
354
|
+
// core/util/detect-image-mimetype.ts
|
355
|
+
var mimeTypeSignatures = [
|
356
|
+
{ mimeType: "image/gif", bytes: [71, 73, 70] },
|
357
|
+
{ mimeType: "image/png", bytes: [137, 80, 78, 71] },
|
358
|
+
{ mimeType: "image/jpeg", bytes: [255, 216] },
|
359
|
+
{ mimeType: "image/webp", bytes: [82, 73, 70, 70] }
|
360
|
+
];
|
361
|
+
function detectImageMimeType(image) {
|
362
|
+
for (const { bytes, mimeType } of mimeTypeSignatures) {
|
363
|
+
if (image.length >= bytes.length && bytes.every((byte, index) => image[index] === byte)) {
|
364
|
+
return mimeType;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
return void 0;
|
368
|
+
}
|
369
|
+
|
354
370
|
// core/prompt/data-content.ts
|
355
371
|
function convertDataContentToBase64String(content) {
|
356
372
|
if (typeof content === "string") {
|
@@ -403,15 +419,26 @@ function convertToLanguageModelPrompt(prompt2) {
|
|
403
419
|
role: "user",
|
404
420
|
content: message.content.map(
|
405
421
|
(part) => {
|
422
|
+
var _a;
|
406
423
|
switch (part.type) {
|
407
424
|
case "text": {
|
408
425
|
return part;
|
409
426
|
}
|
410
427
|
case "image": {
|
428
|
+
if (part.image instanceof URL) {
|
429
|
+
return {
|
430
|
+
type: "image",
|
431
|
+
image: part.image,
|
432
|
+
mimeType: part.mimeType
|
433
|
+
};
|
434
|
+
}
|
435
|
+
const imageUint8 = convertDataContentToUint8Array(
|
436
|
+
part.image
|
437
|
+
);
|
411
438
|
return {
|
412
439
|
type: "image",
|
413
|
-
image:
|
414
|
-
mimeType: part.mimeType
|
440
|
+
image: imageUint8,
|
441
|
+
mimeType: (_a = part.mimeType) != null ? _a : detectImageMimeType(imageUint8)
|
415
442
|
};
|
416
443
|
}
|
417
444
|
}
|