@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/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@ai-sdk/provider-utils";
|
|
12
12
|
|
|
13
13
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "3.0.
|
|
14
|
+
var VERSION = true ? "3.0.9" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-messages-language-model.ts
|
|
17
17
|
import {
|
|
@@ -1572,6 +1572,15 @@ function convertToString(data) {
|
|
|
1572
1572
|
functionality: `unsupported data type for text documents: ${typeof data}`
|
|
1573
1573
|
});
|
|
1574
1574
|
}
|
|
1575
|
+
function isUrlData(data) {
|
|
1576
|
+
return data instanceof URL || isUrlString(data);
|
|
1577
|
+
}
|
|
1578
|
+
function isUrlString(data) {
|
|
1579
|
+
return typeof data === "string" && /^https?:\/\//i.test(data);
|
|
1580
|
+
}
|
|
1581
|
+
function getUrlString(data) {
|
|
1582
|
+
return data instanceof URL ? data.toString() : data;
|
|
1583
|
+
}
|
|
1575
1584
|
async function convertToAnthropicMessagesPrompt({
|
|
1576
1585
|
prompt,
|
|
1577
1586
|
sendReasoning,
|
|
@@ -1655,9 +1664,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1655
1664
|
if (part.mediaType.startsWith("image/")) {
|
|
1656
1665
|
anthropicContent.push({
|
|
1657
1666
|
type: "image",
|
|
1658
|
-
source: part.data
|
|
1667
|
+
source: isUrlData(part.data) ? {
|
|
1659
1668
|
type: "url",
|
|
1660
|
-
url: part.data
|
|
1669
|
+
url: getUrlString(part.data)
|
|
1661
1670
|
} : {
|
|
1662
1671
|
type: "base64",
|
|
1663
1672
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
@@ -1675,9 +1684,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1675
1684
|
);
|
|
1676
1685
|
anthropicContent.push({
|
|
1677
1686
|
type: "document",
|
|
1678
|
-
source: part.data
|
|
1687
|
+
source: isUrlData(part.data) ? {
|
|
1679
1688
|
type: "url",
|
|
1680
|
-
url: part.data
|
|
1689
|
+
url: getUrlString(part.data)
|
|
1681
1690
|
} : {
|
|
1682
1691
|
type: "base64",
|
|
1683
1692
|
media_type: "application/pdf",
|
|
@@ -1699,9 +1708,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1699
1708
|
);
|
|
1700
1709
|
anthropicContent.push({
|
|
1701
1710
|
type: "document",
|
|
1702
|
-
source: part.data
|
|
1711
|
+
source: isUrlData(part.data) ? {
|
|
1703
1712
|
type: "url",
|
|
1704
|
-
url: part.data
|
|
1713
|
+
url: getUrlString(part.data)
|
|
1705
1714
|
} : {
|
|
1706
1715
|
type: "text",
|
|
1707
1716
|
media_type: "text/plain",
|