@ai-sdk/anthropic 3.0.7 → 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 +16 -0
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +17 -8
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +17 -8
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -1541,6 +1541,15 @@ function convertToString(data) {
|
|
|
1541
1541
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1542
1542
|
});
|
|
1543
1543
|
}
|
|
1544
|
+
function isUrlData(data) {
|
|
1545
|
+
return data instanceof URL || isUrlString(data);
|
|
1546
|
+
}
|
|
1547
|
+
function isUrlString(data) {
|
|
1548
|
+
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
1549
|
+
}
|
|
1550
|
+
function getUrlString(data) {
|
|
1551
|
+
return data instanceof URL ? data.toString() : data;
|
|
1552
|
+
}
|
|
1544
1553
|
async function convertToAnthropicMessagesPrompt({
|
|
1545
1554
|
prompt,
|
|
1546
1555
|
sendReasoning,
|
|
@@ -1624,9 +1633,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1624
1633
|
if (part.mediaType.startsWith("image/")) {
|
|
1625
1634
|
anthropicContent.push({
|
|
1626
1635
|
type: "image",
|
|
1627
|
-
source: part.data
|
|
1636
|
+
source: isUrlData(part.data) ? {
|
|
1628
1637
|
type: "url",
|
|
1629
|
-
url: part.data
|
|
1638
|
+
url: getUrlString(part.data)
|
|
1630
1639
|
} : {
|
|
1631
1640
|
type: "base64",
|
|
1632
1641
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
@@ -1644,9 +1653,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1644
1653
|
);
|
|
1645
1654
|
anthropicContent.push({
|
|
1646
1655
|
type: "document",
|
|
1647
|
-
source: part.data
|
|
1656
|
+
source: isUrlData(part.data) ? {
|
|
1648
1657
|
type: "url",
|
|
1649
|
-
url: part.data
|
|
1658
|
+
url: getUrlString(part.data)
|
|
1650
1659
|
} : {
|
|
1651
1660
|
type: "base64",
|
|
1652
1661
|
media_type: "application/pdf",
|
|
@@ -1668,9 +1677,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1668
1677
|
);
|
|
1669
1678
|
anthropicContent.push({
|
|
1670
1679
|
type: "document",
|
|
1671
|
-
source: part.data
|
|
1680
|
+
source: isUrlData(part.data) ? {
|
|
1672
1681
|
type: "url",
|
|
1673
|
-
url: part.data
|
|
1682
|
+
url: getUrlString(part.data)
|
|
1674
1683
|
} : {
|
|
1675
1684
|
type: "text",
|
|
1676
1685
|
media_type: "text/plain",
|
|
@@ -3748,7 +3757,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3748
3757
|
}
|
|
3749
3758
|
};
|
|
3750
3759
|
function getModelCapabilities(modelId) {
|
|
3751
|
-
if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
3760
|
+
if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
3752
3761
|
return {
|
|
3753
3762
|
maxOutputTokens: 64e3,
|
|
3754
3763
|
supportsStructuredOutput: true,
|
|
@@ -3760,7 +3769,7 @@ function getModelCapabilities(modelId) {
|
|
|
3760
3769
|
supportsStructuredOutput: true,
|
|
3761
3770
|
isKnownModel: true
|
|
3762
3771
|
};
|
|
3763
|
-
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")
|
|
3772
|
+
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
|
|
3764
3773
|
return {
|
|
3765
3774
|
maxOutputTokens: 64e3,
|
|
3766
3775
|
supportsStructuredOutput: false,
|