@ai-sdk/anthropic 3.0.21 → 3.0.23
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 +15 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- package/src/anthropic-provider.ts +32 -7
- package/src/__fixtures__/anthropic-code-execution-20250825.1.chunks.txt +0 -248
- package/src/__fixtures__/anthropic-code-execution-20250825.1.json +0 -70
- package/src/__fixtures__/anthropic-code-execution-20250825.2.chunks.txt +0 -984
- package/src/__fixtures__/anthropic-code-execution-20250825.2.json +0 -111
- package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.chunks.txt +0 -691
- package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.json +0 -1801
- package/src/__fixtures__/anthropic-json-other-tool.1.chunks.txt +0 -13
- package/src/__fixtures__/anthropic-json-other-tool.1.json +0 -26
- package/src/__fixtures__/anthropic-json-output-format.1.chunks.txt +0 -120
- package/src/__fixtures__/anthropic-json-output-format.1.json +0 -25
- package/src/__fixtures__/anthropic-json-tool.1.chunks.txt +0 -9
- package/src/__fixtures__/anthropic-json-tool.1.json +0 -37
- package/src/__fixtures__/anthropic-json-tool.2.chunks.txt +0 -14
- package/src/__fixtures__/anthropic-mcp.1.chunks.txt +0 -17
- package/src/__fixtures__/anthropic-mcp.1.json +0 -39
- package/src/__fixtures__/anthropic-memory-20250818.1.json +0 -28
- package/src/__fixtures__/anthropic-message-delta-input-tokens.chunks.txt +0 -8
- package/src/__fixtures__/anthropic-programmatic-tool-calling.1.chunks.txt +0 -278
- package/src/__fixtures__/anthropic-programmatic-tool-calling.1.json +0 -106
- package/src/__fixtures__/anthropic-tool-no-args.chunks.txt +0 -13
- package/src/__fixtures__/anthropic-tool-no-args.json +0 -31
- package/src/__fixtures__/anthropic-tool-search-bm25.1.chunks.txt +0 -47
- package/src/__fixtures__/anthropic-tool-search-bm25.1.json +0 -67
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.2.json +0 -65
- package/src/__fixtures__/anthropic-tool-search-deferred-bm25.chunks.txt +0 -115
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.2.json +0 -69
- package/src/__fixtures__/anthropic-tool-search-deferred-regex.chunks.txt +0 -119
- package/src/__fixtures__/anthropic-tool-search-regex.1.chunks.txt +0 -51
- package/src/__fixtures__/anthropic-tool-search-regex.1.json +0 -65
- package/src/__fixtures__/anthropic-web-fetch-tool.1.chunks.txt +0 -64
- package/src/__fixtures__/anthropic-web-fetch-tool.1.json +0 -54
- package/src/__fixtures__/anthropic-web-fetch-tool.2.json +0 -56
- package/src/__fixtures__/anthropic-web-fetch-tool.error.json +0 -46
- package/src/__fixtures__/anthropic-web-search-tool.1.chunks.txt +0 -120
- package/src/__fixtures__/anthropic-web-search-tool.1.json +0 -181
- package/src/__snapshots__/anthropic-messages-language-model.test.ts.snap +0 -16719
- package/src/anthropic-error.test.ts +0 -42
- package/src/anthropic-messages-language-model.test.ts +0 -7368
- package/src/anthropic-prepare-tools.test.ts +0 -1219
- package/src/anthropic-provider.test.ts +0 -162
- package/src/convert-to-anthropic-messages-prompt.test.ts +0 -2902
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/anthropic-provider.ts
|
|
2
2
|
import {
|
|
3
|
+
InvalidArgumentError,
|
|
3
4
|
NoSuchModelError
|
|
4
5
|
} from "@ai-sdk/provider";
|
|
5
6
|
import {
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
} from "@ai-sdk/provider-utils";
|
|
12
13
|
|
|
13
14
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "3.0.
|
|
15
|
+
var VERSION = true ? "3.0.23" : "0.0.0-test";
|
|
15
16
|
|
|
16
17
|
// src/anthropic-messages-language-model.ts
|
|
17
18
|
import {
|
|
@@ -4372,18 +4373,29 @@ function createAnthropic(options = {}) {
|
|
|
4372
4373
|
})
|
|
4373
4374
|
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
4374
4375
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
4375
|
-
|
|
4376
|
-
{
|
|
4377
|
-
|
|
4376
|
+
if (options.apiKey && options.authToken) {
|
|
4377
|
+
throw new InvalidArgumentError({
|
|
4378
|
+
argument: "apiKey/authToken",
|
|
4379
|
+
message: "Both apiKey and authToken were provided. Please use only one authentication method."
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
4382
|
+
const getHeaders = () => {
|
|
4383
|
+
const authHeaders = options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {
|
|
4378
4384
|
"x-api-key": loadApiKey({
|
|
4379
4385
|
apiKey: options.apiKey,
|
|
4380
4386
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
4381
4387
|
description: "Anthropic"
|
|
4382
|
-
})
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4388
|
+
})
|
|
4389
|
+
};
|
|
4390
|
+
return withUserAgentSuffix(
|
|
4391
|
+
{
|
|
4392
|
+
"anthropic-version": "2023-06-01",
|
|
4393
|
+
...authHeaders,
|
|
4394
|
+
...options.headers
|
|
4395
|
+
},
|
|
4396
|
+
`ai-sdk/anthropic/${VERSION}`
|
|
4397
|
+
);
|
|
4398
|
+
};
|
|
4387
4399
|
const createChatModel = (modelId) => {
|
|
4388
4400
|
var _a2;
|
|
4389
4401
|
return new AnthropicMessagesLanguageModel(modelId, {
|