@core-ai/anthropic 0.11.1 → 0.13.0
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/dist/index.d.ts +5 -2
- package/dist/index.js +60 -68
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import { ChatModel } from '@core-ai/core-ai';
|
|
2
|
+
import { ChatModel, ModelCapabilities } from '@core-ai/core-ai';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
type AnthropicProviderOptions$1 = {
|
|
@@ -18,6 +18,9 @@ type AnthropicReasoningMetadata = {
|
|
|
18
18
|
redactedData?: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
type AnthropicModelCapabilities = ModelCapabilities;
|
|
22
|
+
declare function getAnthropicModelCapabilities(modelId: string): AnthropicModelCapabilities;
|
|
23
|
+
|
|
21
24
|
declare const anthropicCacheControlSchema: z.ZodObject<{
|
|
22
25
|
type: z.ZodLiteral<"ephemeral">;
|
|
23
26
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
@@ -60,4 +63,4 @@ declare const anthropicProviderOptionsSchema: z.ZodObject<{
|
|
|
60
63
|
}, z.core.$strict>;
|
|
61
64
|
type AnthropicProviderOptions = AnthropicGenerateProviderOptions;
|
|
62
65
|
|
|
63
|
-
export { type AnthropicCacheControl, type AnthropicGenerateProviderOptions, type AnthropicProviderOptions as AnthropicModelProviderOptions, type AnthropicProvider, type AnthropicProviderOptions$1 as AnthropicProviderOptions, type AnthropicReasoningMetadata, anthropicCacheControlSchema, anthropicGenerateProviderOptionsSchema, anthropicProviderOptionsSchema, createAnthropic };
|
|
66
|
+
export { type AnthropicCacheControl, type AnthropicGenerateProviderOptions, type AnthropicModelCapabilities, type AnthropicProviderOptions as AnthropicModelProviderOptions, type AnthropicProvider, type AnthropicProviderOptions$1 as AnthropicProviderOptions, type AnthropicReasoningMetadata, anthropicCacheControlSchema, anthropicGenerateProviderOptionsSchema, anthropicProviderOptionsSchema, createAnthropic, getAnthropicModelCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -23,70 +23,52 @@ import {
|
|
|
23
23
|
} from "@core-ai/core-ai";
|
|
24
24
|
|
|
25
25
|
// src/model-capabilities.ts
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"claude-opus-4-7": ADAPTIVE_MAX_EFFORT_CAPABILITIES,
|
|
45
|
-
"claude-opus-4-6": ADAPTIVE_MAX_EFFORT_CAPABILITIES,
|
|
46
|
-
"claude-sonnet-4-6": ADAPTIVE_MAX_EFFORT_CAPABILITIES,
|
|
47
|
-
"claude-opus-4-5": {
|
|
48
|
-
reasoning: {
|
|
49
|
-
thinkingMode: "manual",
|
|
50
|
-
supportsMaxEffort: false
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"claude-sonnet-4-5": {
|
|
54
|
-
reasoning: {
|
|
55
|
-
thinkingMode: "manual",
|
|
56
|
-
supportsMaxEffort: false
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"claude-opus-4-1": {
|
|
60
|
-
reasoning: {
|
|
61
|
-
thinkingMode: "manual",
|
|
62
|
-
supportsMaxEffort: false
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"claude-opus-4": {
|
|
66
|
-
reasoning: {
|
|
67
|
-
thinkingMode: "manual",
|
|
68
|
-
supportsMaxEffort: false
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"claude-sonnet-4": {
|
|
72
|
-
reasoning: {
|
|
73
|
-
thinkingMode: "manual",
|
|
74
|
-
supportsMaxEffort: false
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
"claude-haiku-4-5": {
|
|
78
|
-
reasoning: {
|
|
79
|
-
thinkingMode: "manual",
|
|
80
|
-
supportsMaxEffort: false
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"claude-sonnet-3-7": {
|
|
26
|
+
import {
|
|
27
|
+
stripModelDateSuffix
|
|
28
|
+
} from "@core-ai/core-ai";
|
|
29
|
+
var STANDARD_EFFORTS = [
|
|
30
|
+
"minimal",
|
|
31
|
+
"low",
|
|
32
|
+
"medium",
|
|
33
|
+
"high"
|
|
34
|
+
];
|
|
35
|
+
var MAX_EFFORTS = [
|
|
36
|
+
"minimal",
|
|
37
|
+
"low",
|
|
38
|
+
"medium",
|
|
39
|
+
"high",
|
|
40
|
+
"max"
|
|
41
|
+
];
|
|
42
|
+
function createCapabilities(supportedEfforts) {
|
|
43
|
+
return {
|
|
84
44
|
reasoning: {
|
|
85
|
-
|
|
86
|
-
|
|
45
|
+
supported: true,
|
|
46
|
+
supportedEfforts,
|
|
47
|
+
restrictsSamplingParams: true
|
|
87
48
|
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var STANDARD_CAPABILITIES = createCapabilities(STANDARD_EFFORTS);
|
|
52
|
+
var MAX_EFFORT_CAPABILITIES = createCapabilities(MAX_EFFORTS);
|
|
53
|
+
var ADAPTIVE_MAX_EFFORT_MODELS = /* @__PURE__ */ new Set([
|
|
54
|
+
"claude-fable-5",
|
|
55
|
+
"claude-mythos-5",
|
|
56
|
+
"claude-mythos-preview",
|
|
57
|
+
"claude-opus-4-8",
|
|
58
|
+
"claude-opus-4-7",
|
|
59
|
+
"claude-opus-4-6",
|
|
60
|
+
"claude-sonnet-5",
|
|
61
|
+
"claude-sonnet-4-6"
|
|
62
|
+
]);
|
|
63
|
+
var MANUAL_THINKING_MODELS = /* @__PURE__ */ new Set([
|
|
64
|
+
"claude-opus-4-5",
|
|
65
|
+
"claude-sonnet-4-5",
|
|
66
|
+
"claude-opus-4-1",
|
|
67
|
+
"claude-opus-4",
|
|
68
|
+
"claude-sonnet-4",
|
|
69
|
+
"claude-haiku-4-5",
|
|
70
|
+
"claude-sonnet-3-7"
|
|
71
|
+
]);
|
|
90
72
|
var ANTHROPIC_ADAPTIVE_EFFORT_MAP = {
|
|
91
73
|
minimal: "low",
|
|
92
74
|
low: "low",
|
|
@@ -101,12 +83,20 @@ var ANTHROPIC_MANUAL_BUDGET_MAP = {
|
|
|
101
83
|
max: 65536
|
|
102
84
|
};
|
|
103
85
|
function getAnthropicModelCapabilities(modelId) {
|
|
104
|
-
|
|
105
|
-
|
|
86
|
+
if (supportsAnthropicMaxEffort(modelId) || getAnthropicThinkingMode(modelId) === "manual") {
|
|
87
|
+
return MAX_EFFORT_CAPABILITIES;
|
|
88
|
+
}
|
|
89
|
+
return STANDARD_CAPABILITIES;
|
|
106
90
|
}
|
|
107
91
|
function normalizeModelId(modelId) {
|
|
108
92
|
return stripModelDateSuffix(modelId);
|
|
109
93
|
}
|
|
94
|
+
function getAnthropicThinkingMode(modelId) {
|
|
95
|
+
return MANUAL_THINKING_MODELS.has(normalizeModelId(modelId)) ? "manual" : "adaptive";
|
|
96
|
+
}
|
|
97
|
+
function supportsAnthropicMaxEffort(modelId) {
|
|
98
|
+
return ADAPTIVE_MAX_EFFORT_MODELS.has(normalizeModelId(modelId));
|
|
99
|
+
}
|
|
110
100
|
function toAnthropicAdaptiveEffort(effort, supportsMaxEffort) {
|
|
111
101
|
if (effort === "max") {
|
|
112
102
|
return supportsMaxEffort ? "max" : "high";
|
|
@@ -462,17 +452,17 @@ function mapReasoningToRequestFields(modelId, options) {
|
|
|
462
452
|
if (!options.reasoning) {
|
|
463
453
|
return {};
|
|
464
454
|
}
|
|
465
|
-
const
|
|
455
|
+
const thinkingMode = getAnthropicThinkingMode(modelId);
|
|
466
456
|
const baseFields = {};
|
|
467
457
|
if (options.tools && Object.keys(options.tools).length > 0) {
|
|
468
458
|
baseFields["betas"] = ["interleaved-thinking-2025-05-14"];
|
|
469
459
|
}
|
|
470
|
-
if (
|
|
460
|
+
if (thinkingMode === "adaptive") {
|
|
471
461
|
baseFields["thinking"] = { type: "adaptive" };
|
|
472
462
|
baseFields["output_config"] = {
|
|
473
463
|
effort: toAnthropicAdaptiveEffort(
|
|
474
464
|
options.reasoning.effort,
|
|
475
|
-
|
|
465
|
+
supportsAnthropicMaxEffort(modelId)
|
|
476
466
|
)
|
|
477
467
|
};
|
|
478
468
|
return baseFields;
|
|
@@ -816,6 +806,7 @@ function createAnthropicChatModel(client, modelId, defaultMaxTokens) {
|
|
|
816
806
|
return {
|
|
817
807
|
provider,
|
|
818
808
|
modelId,
|
|
809
|
+
capabilities: getAnthropicModelCapabilities(modelId),
|
|
819
810
|
generate: generateChat,
|
|
820
811
|
stream: streamChat,
|
|
821
812
|
async generateObject(options) {
|
|
@@ -981,5 +972,6 @@ export {
|
|
|
981
972
|
anthropicCacheControlSchema,
|
|
982
973
|
anthropicGenerateProviderOptionsSchema,
|
|
983
974
|
anthropicProviderOptionsSchema,
|
|
984
|
-
createAnthropic
|
|
975
|
+
createAnthropic,
|
|
976
|
+
getAnthropicModelCapabilities
|
|
985
977
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Anthropic provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"test:watch": "vitest"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@core-ai/core-ai": "^0.
|
|
47
|
+
"@core-ai/core-ai": "^0.13.0",
|
|
48
48
|
"@anthropic-ai/sdk": "^0.78.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|