@ai-sdk/anthropic 4.0.0-beta.16 → 4.0.0-beta.17
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 +9 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1162 -1060
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1162 -1050
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +20 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-files.ts +106 -0
- package/src/anthropic-messages-api.ts +4 -0
- package/src/anthropic-provider.ts +13 -1
- package/src/convert-to-anthropic-messages-prompt.ts +23 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -1666,7 +1666,9 @@ import {
|
|
|
1666
1666
|
import {
|
|
1667
1667
|
convertBase64ToUint8Array,
|
|
1668
1668
|
convertToBase64,
|
|
1669
|
+
isProviderReference,
|
|
1669
1670
|
parseProviderOptions,
|
|
1671
|
+
resolveProviderReference,
|
|
1670
1672
|
validateTypes as validateTypes2,
|
|
1671
1673
|
isNonNullable
|
|
1672
1674
|
} from "@ai-sdk/provider-utils";
|
|
@@ -2098,7 +2100,26 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2098
2100
|
break;
|
|
2099
2101
|
}
|
|
2100
2102
|
case "file": {
|
|
2101
|
-
if (part.
|
|
2103
|
+
if (isProviderReference(part.data)) {
|
|
2104
|
+
const fileId = resolveProviderReference({
|
|
2105
|
+
reference: part.data,
|
|
2106
|
+
provider: "anthropic"
|
|
2107
|
+
});
|
|
2108
|
+
betas.add("files-api-2025-04-14");
|
|
2109
|
+
if (part.mediaType.startsWith("image/")) {
|
|
2110
|
+
anthropicContent.push({
|
|
2111
|
+
type: "image",
|
|
2112
|
+
source: { type: "file", file_id: fileId },
|
|
2113
|
+
cache_control: cacheControl
|
|
2114
|
+
});
|
|
2115
|
+
} else {
|
|
2116
|
+
anthropicContent.push({
|
|
2117
|
+
type: "document",
|
|
2118
|
+
source: { type: "file", file_id: fileId },
|
|
2119
|
+
cache_control: cacheControl
|
|
2120
|
+
});
|
|
2121
|
+
}
|
|
2122
|
+
} else if (part.mediaType.startsWith("image/")) {
|
|
2102
2123
|
anthropicContent.push({
|
|
2103
2124
|
type: "image",
|
|
2104
2125
|
source: isUrlData(part.data) ? {
|