@molecule/api-ai-anthropic 1.0.1 → 1.1.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/provider.d.ts.map +1 -1
- package/dist/provider.js +10 -3
- package/package.json +2 -2
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EAQX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EAQX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAoqBjD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAEnE"}
|
package/dist/provider.js
CHANGED
|
@@ -68,8 +68,11 @@ class AnthropicAIProvider {
|
|
|
68
68
|
// Fail fast with an actionable local error rather than a cryptic 401 on the
|
|
69
69
|
// first request. The default `provider` export constructs lazily on first
|
|
70
70
|
// use (see index.ts), so this surfaces the moment the provider is actually
|
|
71
|
-
// used, not at bond/module-load time.
|
|
72
|
-
|
|
71
|
+
// used, not at bond/module-load time. A key is required only for the
|
|
72
|
+
// official endpoint — a custom baseUrl may target a keyless self-hosted /
|
|
73
|
+
// local server, where the auth header is omitted below.
|
|
74
|
+
const usingCustomEndpoint = Boolean(config.baseUrl ?? process.env.ANTHROPIC_BASE_URL);
|
|
75
|
+
if (!this.apiKey && !usingCustomEndpoint) {
|
|
73
76
|
throw new Error('ANTHROPIC_API_KEY is not set. Add it to your environment to use the Anthropic Claude AI provider.');
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -84,6 +87,9 @@ class AnthropicAIProvider {
|
|
|
84
87
|
const maxTokens = params.maxTokens ?? this.maxTokens;
|
|
85
88
|
const formattedMessages = this.formatMessages(params.messages);
|
|
86
89
|
const body = {
|
|
90
|
+
// BYO / provider-native tunables (top_k, top_p, …). Spread FIRST so the
|
|
91
|
+
// structural fields below always win and cannot be broken.
|
|
92
|
+
...(params.extraBody ?? {}),
|
|
87
93
|
model,
|
|
88
94
|
max_tokens: maxTokens,
|
|
89
95
|
messages: formattedMessages,
|
|
@@ -163,7 +169,8 @@ class AnthropicAIProvider {
|
|
|
163
169
|
}
|
|
164
170
|
const headers = {
|
|
165
171
|
'Content-Type': 'application/json',
|
|
166
|
-
|
|
172
|
+
// Omitted for a keyless custom endpoint (a self-hosted / local server).
|
|
173
|
+
...(this.apiKey ? { 'x-api-key': this.apiKey } : {}),
|
|
167
174
|
'anthropic-version': '2023-06-01',
|
|
168
175
|
};
|
|
169
176
|
// Build anthropic-beta header — features that require beta flags.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-anthropic",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Anthropic Claude AI provider for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"directory": "packages/api/bonds/ai/anthropic"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@molecule/api-ai": "1.0
|
|
35
|
+
"@molecule/api-ai": "1.1.0",
|
|
36
36
|
"@molecule/api-bond": "1.0.1",
|
|
37
37
|
"@types/node": "26.1.2",
|
|
38
38
|
"typescript": "6.0.3",
|