@aigne/anthropic 0.11.4 → 0.11.7

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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.7](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.6...anthropic-v0.11.7) (2025-08-21)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * dependencies
10
+ * @aigne/core bumped to 1.54.0
11
+ * devDependencies
12
+ * @aigne/test-utils bumped to 0.5.33
13
+
14
+ ## [0.11.6](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.5...anthropic-v0.11.6) (2025-08-20)
15
+
16
+
17
+ ### Dependencies
18
+
19
+ * The following workspace dependencies were updated
20
+ * dependencies
21
+ * @aigne/core bumped to 1.53.0
22
+ * devDependencies
23
+ * @aigne/test-utils bumped to 0.5.32
24
+
25
+ ## [0.11.5](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.4...anthropic-v0.11.5) (2025-08-20)
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @aigne/core bumped to 1.52.0
33
+ * devDependencies
34
+ * @aigne/test-utils bumped to 0.5.31
35
+
3
36
  ## [0.11.4](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.3...anthropic-v0.11.4) (2025-08-18)
4
37
 
5
38
 
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- client(): Promise<Anthropic>;
107
+ get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): Promise<{
109
+ get credential(): {
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- }>;
112
+ };
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -62,8 +62,8 @@ class AnthropicChatModel extends core_1.ChatModel {
62
62
  * @hidden
63
63
  */
64
64
  _client;
65
- async client() {
66
- const { apiKey } = await this.getCredential();
65
+ get client() {
66
+ const { apiKey } = this.credential;
67
67
  if (!apiKey)
68
68
  throw new Error("AnthropicChatModel requires an API key. Please provide it via `options.apiKey`, or set the `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` environment variable");
69
69
  this._client ??= new sdk_1.default({
@@ -76,7 +76,7 @@ class AnthropicChatModel extends core_1.ChatModel {
76
76
  get modelOptions() {
77
77
  return this.options?.modelOptions;
78
78
  }
79
- async getCredential() {
79
+ get credential() {
80
80
  const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
81
81
  return {
82
82
  apiKey,
@@ -108,7 +108,7 @@ class AnthropicChatModel extends core_1.ChatModel {
108
108
  }
109
109
  ajv = new ajv_1.Ajv();
110
110
  async _process(input) {
111
- const { model } = await this.getCredential();
111
+ const model = input.modelOptions?.model || this.credential.model;
112
112
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
113
113
  this.modelOptions?.parallelToolCalls === false;
114
114
  const body = {
@@ -125,8 +125,7 @@ class AnthropicChatModel extends core_1.ChatModel {
125
125
  if (!input.tools?.length && input.responseFormat?.type === "json_schema") {
126
126
  return this.requestStructuredOutput(body, input.responseFormat);
127
127
  }
128
- const client = await this.client();
129
- const stream = client.messages.stream({
128
+ const stream = this.client.messages.stream({
130
129
  ...body,
131
130
  stream: true,
132
131
  });
@@ -231,8 +230,7 @@ class AnthropicChatModel extends core_1.ChatModel {
231
230
  if (responseFormat?.type !== "json_schema") {
232
231
  throw new Error("Expected json_schema response format");
233
232
  }
234
- const client = await this.client();
235
- const result = await client.messages.create({
233
+ const result = await this.client.messages.create({
236
234
  ...body,
237
235
  tools: [
238
236
  {
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- client(): Promise<Anthropic>;
107
+ get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): Promise<{
109
+ get credential(): {
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- }>;
112
+ };
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- client(): Promise<Anthropic>;
107
+ get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): Promise<{
109
+ get credential(): {
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- }>;
112
+ };
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -56,8 +56,8 @@ export class AnthropicChatModel extends ChatModel {
56
56
  * @hidden
57
57
  */
58
58
  _client;
59
- async client() {
60
- const { apiKey } = await this.getCredential();
59
+ get client() {
60
+ const { apiKey } = this.credential;
61
61
  if (!apiKey)
62
62
  throw new Error("AnthropicChatModel requires an API key. Please provide it via `options.apiKey`, or set the `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` environment variable");
63
63
  this._client ??= new Anthropic({
@@ -70,7 +70,7 @@ export class AnthropicChatModel extends ChatModel {
70
70
  get modelOptions() {
71
71
  return this.options?.modelOptions;
72
72
  }
73
- async getCredential() {
73
+ get credential() {
74
74
  const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
75
75
  return {
76
76
  apiKey,
@@ -102,7 +102,7 @@ export class AnthropicChatModel extends ChatModel {
102
102
  }
103
103
  ajv = new Ajv();
104
104
  async _process(input) {
105
- const { model } = await this.getCredential();
105
+ const model = input.modelOptions?.model || this.credential.model;
106
106
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
107
107
  this.modelOptions?.parallelToolCalls === false;
108
108
  const body = {
@@ -119,8 +119,7 @@ export class AnthropicChatModel extends ChatModel {
119
119
  if (!input.tools?.length && input.responseFormat?.type === "json_schema") {
120
120
  return this.requestStructuredOutput(body, input.responseFormat);
121
121
  }
122
- const client = await this.client();
123
- const stream = client.messages.stream({
122
+ const stream = this.client.messages.stream({
124
123
  ...body,
125
124
  stream: true,
126
125
  });
@@ -225,8 +224,7 @@ export class AnthropicChatModel extends ChatModel {
225
224
  if (responseFormat?.type !== "json_schema") {
226
225
  throw new Error("Expected json_schema response format");
227
226
  }
228
- const client = await this.client();
229
- const result = await client.messages.create({
227
+ const result = await this.client.messages.create({
230
228
  ...body,
231
229
  tools: [
232
230
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/anthropic",
3
- "version": "0.11.4",
3
+ "version": "0.11.7",
4
4
  "description": "AIGNE Anthropic SDK for integrating with Claude AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,7 +38,7 @@
38
38
  "@anthropic-ai/sdk": "^0.56.0",
39
39
  "ajv": "^8.17.1",
40
40
  "zod": "^3.25.67",
41
- "@aigne/core": "^1.51.0"
41
+ "@aigne/core": "^1.54.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/bun": "^1.2.18",
@@ -46,7 +46,7 @@
46
46
  "npm-run-all": "^4.1.5",
47
47
  "rimraf": "^6.0.1",
48
48
  "typescript": "^5.8.3",
49
- "@aigne/test-utils": "^0.5.30"
49
+ "@aigne/test-utils": "^0.5.33"
50
50
  },
51
51
  "scripts": {
52
52
  "lint": "tsc --noEmit",