@ai-sdk/anthropic 4.0.72 → 4.0.74
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 +31 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +2 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +9 -0
- package/package.json +5 -5
- package/src/anthropic-batch.ts +2 -0
- package/src/anthropic-files.ts +3 -1
- package/src/anthropic-language-model.ts +1 -0
- package/src/anthropic-provider.ts +7 -0
- package/src/skills/anthropic-skills.ts +5 -1
package/docs/05-anthropic.mdx
CHANGED
|
@@ -33,6 +33,15 @@ const anthropic = createAnthropic({
|
|
|
33
33
|
|
|
34
34
|
You can use the following optional settings to customize the Anthropic provider instance:
|
|
35
35
|
|
|
36
|
+
- **batchResultDownloads** _object_
|
|
37
|
+
|
|
38
|
+
Settings for downloading JSON Lines batch results.
|
|
39
|
+
- **maxLineBytes** _number_
|
|
40
|
+
|
|
41
|
+
Maximum UTF-8 bytes per row, excluding the LF delimiter. Defaults to 64 MiB
|
|
42
|
+
(67,108,864 bytes). Must be a positive safe integer. Oversized rows throw a
|
|
43
|
+
`DownloadError` and cancel the download.
|
|
44
|
+
|
|
36
45
|
- **baseURL** _string_
|
|
37
46
|
|
|
38
47
|
Use a different URL prefix for API calls, e.g. to use proxy servers.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/anthropic",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.74",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.24",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.56"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@ai-sdk/test-server": "2.0.
|
|
42
|
+
"@ai-sdk/test-server": "2.0.4",
|
|
43
43
|
"@types/node": "22.19.19",
|
|
44
44
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
45
45
|
"tsdown": "^0.23.0",
|
|
46
|
-
"typescript": "
|
|
46
|
+
"typescript": "6.0.3",
|
|
47
47
|
"zod": "3.25.76"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
package/src/anthropic-batch.ts
CHANGED
|
@@ -189,6 +189,7 @@ export class AnthropicBatch implements BatchV4<{
|
|
|
189
189
|
provider: string;
|
|
190
190
|
config: AnthropicLanguageModelConfig;
|
|
191
191
|
supportedUrls: Record<string, RegExp[]>;
|
|
192
|
+
maxLineBytes?: number;
|
|
192
193
|
},
|
|
193
194
|
) {
|
|
194
195
|
this.provider = options.provider;
|
|
@@ -409,6 +410,7 @@ export class AnthropicBatch implements BatchV4<{
|
|
|
409
410
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
410
411
|
successfulResponseHandler: createJsonLinesResponseHandler(
|
|
411
412
|
anthropicBatchResultLineSchema,
|
|
413
|
+
{ maxLineBytes: this.options.maxLineBytes },
|
|
412
414
|
),
|
|
413
415
|
abortSignal: options.abortSignal,
|
|
414
416
|
fetch: this.options.config.fetch,
|
package/src/anthropic-files.ts
CHANGED
|
@@ -54,7 +54,9 @@ export class AnthropicFiles implements FilesV4 {
|
|
|
54
54
|
}: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult> {
|
|
55
55
|
const fileBytes = convertInlineFileDataToUint8Array(data);
|
|
56
56
|
|
|
57
|
-
const blob = new Blob([fileBytes], {
|
|
57
|
+
const blob = new Blob([fileBytes as Uint8Array<ArrayBuffer>], {
|
|
58
|
+
type: mediaType,
|
|
59
|
+
});
|
|
58
60
|
|
|
59
61
|
const formData = new FormData();
|
|
60
62
|
if (filename != null) {
|
|
@@ -82,6 +82,12 @@ export interface AnthropicProvider extends ProviderV4 {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export interface AnthropicProviderSettings {
|
|
85
|
+
/** Settings for downloading JSON Lines batch results. */
|
|
86
|
+
batchResultDownloads?: {
|
|
87
|
+
/** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
|
|
88
|
+
maxLineBytes?: number;
|
|
89
|
+
};
|
|
90
|
+
|
|
85
91
|
/**
|
|
86
92
|
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
87
93
|
* The default prefix is `https://api.anthropic.com/v1`.
|
|
@@ -187,6 +193,7 @@ export function createAnthropic(
|
|
|
187
193
|
const createBatch = () =>
|
|
188
194
|
new AnthropicBatch({
|
|
189
195
|
provider: `${providerName.replace(/\.messages$/, '')}.batch`,
|
|
196
|
+
maxLineBytes: options.batchResultDownloads?.maxLineBytes,
|
|
190
197
|
config: languageModelConfig,
|
|
191
198
|
supportedUrls,
|
|
192
199
|
});
|
|
@@ -89,7 +89,11 @@ export class AnthropicSkills implements SkillsV4 {
|
|
|
89
89
|
|
|
90
90
|
for (const file of params.files) {
|
|
91
91
|
const content = convertInlineFileDataToUint8Array(file.data);
|
|
92
|
-
formData.append(
|
|
92
|
+
formData.append(
|
|
93
|
+
'files[]',
|
|
94
|
+
new Blob([content as Uint8Array<ArrayBuffer>]),
|
|
95
|
+
file.path,
|
|
96
|
+
);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
const headers = await this.getHeaders();
|