@aigne/anthropic 0.3.10 → 0.5.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/CHANGELOG.md +32 -0
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/lib/cjs/anthropic-chat-model.d.ts +5 -1
- package/lib/cjs/anthropic-chat-model.js +4 -1
- package/lib/dts/anthropic-chat-model.d.ts +5 -1
- package/lib/esm/anthropic-chat-model.d.ts +5 -1
- package/lib/esm/anthropic-chat-model.js +4 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.0](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.4.0...anthropic-v0.5.0) (2025-07-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **example:** use AIGNE cli to run chat-bot example ([#198](https://github.com/AIGNE-io/aigne-framework/issues/198)) ([7085541](https://github.com/AIGNE-io/aigne-framework/commit/708554100692f2a557f7329ea78e46c3c870ce10))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/core bumped to 1.28.0
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @aigne/test-utils bumped to 0.4.12
|
|
18
|
+
|
|
19
|
+
## [0.4.0](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.3.10...anthropic-v0.4.0) (2025-07-01)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **cli:** support HTTPS_PROXY and named path param ([#196](https://github.com/AIGNE-io/aigne-framework/issues/196)) ([04e684e](https://github.com/AIGNE-io/aigne-framework/commit/04e684ee26bc2d79924b0e3cb541cd07a7191804))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @aigne/core bumped to 1.27.0
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @aigne/test-utils bumped to 0.4.11
|
|
34
|
+
|
|
3
35
|
## [0.3.10](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.3.9...anthropic-v0.3.10) (2025-06-30)
|
|
4
36
|
|
|
5
37
|
|
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ console.log(result);
|
|
|
82
82
|
|
|
83
83
|
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model-streaming-async-generator"
|
|
84
84
|
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
85
|
+
import { isAgentResponseDelta } from "@aigne/core";
|
|
85
86
|
|
|
86
87
|
const model = new AnthropicChatModel({
|
|
87
88
|
apiKey: "your-api-key",
|
|
@@ -92,7 +93,6 @@ const stream = await model.invoke(
|
|
|
92
93
|
{
|
|
93
94
|
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
94
95
|
},
|
|
95
|
-
undefined,
|
|
96
96
|
{ streaming: true },
|
|
97
97
|
);
|
|
98
98
|
|
|
@@ -100,9 +100,11 @@ let fullText = "";
|
|
|
100
100
|
const json = {};
|
|
101
101
|
|
|
102
102
|
for await (const chunk of stream) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
if (isAgentResponseDelta(chunk)) {
|
|
104
|
+
const text = chunk.delta.text?.text;
|
|
105
|
+
if (text) fullText += text;
|
|
106
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
console.log(fullText); // Output: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?"
|
package/README.zh.md
CHANGED
|
@@ -82,6 +82,7 @@ console.log(result);
|
|
|
82
82
|
|
|
83
83
|
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model-streaming-async-generator"
|
|
84
84
|
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
85
|
+
import { isAgentResponseDelta } from "@aigne/core";
|
|
85
86
|
|
|
86
87
|
const model = new AnthropicChatModel({
|
|
87
88
|
apiKey: "your-api-key",
|
|
@@ -92,7 +93,6 @@ const stream = await model.invoke(
|
|
|
92
93
|
{
|
|
93
94
|
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
94
95
|
},
|
|
95
|
-
undefined,
|
|
96
96
|
{ streaming: true },
|
|
97
97
|
);
|
|
98
98
|
|
|
@@ -100,9 +100,11 @@ let fullText = "";
|
|
|
100
100
|
const json = {};
|
|
101
101
|
|
|
102
102
|
for await (const chunk of stream) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
if (isAgentResponseDelta(chunk)) {
|
|
104
|
+
const text = chunk.delta.text?.text;
|
|
105
|
+
if (text) fullText += text;
|
|
106
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
console.log(fullText); // Output: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
3
|
+
import Anthropic, { type ClientOptions } from "@anthropic-ai/sdk";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for Claude Chat Model
|
|
@@ -22,6 +22,10 @@ export interface AnthropicChatModelOptions {
|
|
|
22
22
|
* Additional model options to control behavior
|
|
23
23
|
*/
|
|
24
24
|
modelOptions?: ChatModelOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Optional client options for the Anthropic SDK
|
|
27
|
+
*/
|
|
28
|
+
clientOptions?: Partial<ClientOptions>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* @hidden
|
|
@@ -63,7 +63,10 @@ class AnthropicChatModel extends core_1.ChatModel {
|
|
|
63
63
|
const apiKey = this.options?.apiKey || process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_API_KEY;
|
|
64
64
|
if (!apiKey)
|
|
65
65
|
throw new Error("Api Key is required for AnthropicChatModel");
|
|
66
|
-
this._client ??= new sdk_1.default({
|
|
66
|
+
this._client ??= new sdk_1.default({
|
|
67
|
+
apiKey,
|
|
68
|
+
...this.options?.clientOptions,
|
|
69
|
+
});
|
|
67
70
|
return this._client;
|
|
68
71
|
}
|
|
69
72
|
get modelOptions() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
3
|
+
import Anthropic, { type ClientOptions } from "@anthropic-ai/sdk";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for Claude Chat Model
|
|
@@ -22,6 +22,10 @@ export interface AnthropicChatModelOptions {
|
|
|
22
22
|
* Additional model options to control behavior
|
|
23
23
|
*/
|
|
24
24
|
modelOptions?: ChatModelOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Optional client options for the Anthropic SDK
|
|
27
|
+
*/
|
|
28
|
+
clientOptions?: Partial<ClientOptions>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* @hidden
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
|
|
2
2
|
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
3
|
+
import Anthropic, { type ClientOptions } from "@anthropic-ai/sdk";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for Claude Chat Model
|
|
@@ -22,6 +22,10 @@ export interface AnthropicChatModelOptions {
|
|
|
22
22
|
* Additional model options to control behavior
|
|
23
23
|
*/
|
|
24
24
|
modelOptions?: ChatModelOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Optional client options for the Anthropic SDK
|
|
27
|
+
*/
|
|
28
|
+
clientOptions?: Partial<ClientOptions>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* @hidden
|
|
@@ -57,7 +57,10 @@ export class AnthropicChatModel extends ChatModel {
|
|
|
57
57
|
const apiKey = this.options?.apiKey || process.env.ANTHROPIC_API_KEY || process.env.CLAUDE_API_KEY;
|
|
58
58
|
if (!apiKey)
|
|
59
59
|
throw new Error("Api Key is required for AnthropicChatModel");
|
|
60
|
-
this._client ??= new Anthropic({
|
|
60
|
+
this._client ??= new Anthropic({
|
|
61
|
+
apiKey,
|
|
62
|
+
...this.options?.clientOptions,
|
|
63
|
+
});
|
|
61
64
|
return this._client;
|
|
62
65
|
}
|
|
63
66
|
get modelOptions() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "AIGNE Anthropic SDK for integrating with Claude AI models",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@anthropic-ai/sdk": "^0.41.0",
|
|
36
36
|
"zod": "^3.24.4",
|
|
37
|
-
"@aigne/core": "^1.
|
|
37
|
+
"@aigne/core": "^1.28.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/bun": "^1.2.12",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"npm-run-all": "^4.1.5",
|
|
43
43
|
"rimraf": "^6.0.1",
|
|
44
44
|
"typescript": "^5.8.3",
|
|
45
|
-
"@aigne/test-utils": "^0.4.
|
|
45
|
+
"@aigne/test-utils": "^0.4.12"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"lint": "tsc --noEmit",
|