@ai-sdk/anthropic 3.0.8 → 3.0.9
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 +6 -0
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +15 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +15 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
32
32
|
var import_provider_utils22 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "3.0.
|
|
35
|
+
var VERSION = true ? "3.0.9" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -1549,6 +1549,15 @@ function convertToString(data) {
|
|
|
1549
1549
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1550
1550
|
});
|
|
1551
1551
|
}
|
|
1552
|
+
function isUrlData(data) {
|
|
1553
|
+
return data instanceof URL || isUrlString(data);
|
|
1554
|
+
}
|
|
1555
|
+
function isUrlString(data) {
|
|
1556
|
+
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
1557
|
+
}
|
|
1558
|
+
function getUrlString(data) {
|
|
1559
|
+
return data instanceof URL ? data.toString() : data;
|
|
1560
|
+
}
|
|
1552
1561
|
async function convertToAnthropicMessagesPrompt({
|
|
1553
1562
|
prompt,
|
|
1554
1563
|
sendReasoning,
|
|
@@ -1632,9 +1641,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1632
1641
|
if (part.mediaType.startsWith("image/")) {
|
|
1633
1642
|
anthropicContent.push({
|
|
1634
1643
|
type: "image",
|
|
1635
|
-
source: part.data
|
|
1644
|
+
source: isUrlData(part.data) ? {
|
|
1636
1645
|
type: "url",
|
|
1637
|
-
url: part.data
|
|
1646
|
+
url: getUrlString(part.data)
|
|
1638
1647
|
} : {
|
|
1639
1648
|
type: "base64",
|
|
1640
1649
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
@@ -1652,9 +1661,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1652
1661
|
);
|
|
1653
1662
|
anthropicContent.push({
|
|
1654
1663
|
type: "document",
|
|
1655
|
-
source: part.data
|
|
1664
|
+
source: isUrlData(part.data) ? {
|
|
1656
1665
|
type: "url",
|
|
1657
|
-
url: part.data
|
|
1666
|
+
url: getUrlString(part.data)
|
|
1658
1667
|
} : {
|
|
1659
1668
|
type: "base64",
|
|
1660
1669
|
media_type: "application/pdf",
|
|
@@ -1676,9 +1685,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1676
1685
|
);
|
|
1677
1686
|
anthropicContent.push({
|
|
1678
1687
|
type: "document",
|
|
1679
|
-
source: part.data
|
|
1688
|
+
source: isUrlData(part.data) ? {
|
|
1680
1689
|
type: "url",
|
|
1681
|
-
url: part.data
|
|
1690
|
+
url: getUrlString(part.data)
|
|
1682
1691
|
} : {
|
|
1683
1692
|
type: "text",
|
|
1684
1693
|
media_type: "text/plain",
|