@aigne/anthropic 0.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/CHANGELOG.md +17 -0
- package/LICENSE.md +93 -0
- package/README.md +114 -0
- package/README.zh.md +114 -0
- package/lib/cjs/anthropic-chat-model.d.ts +113 -0
- package/lib/cjs/anthropic-chat-model.js +317 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +17 -0
- package/lib/cjs/package.json +1 -0
- package/lib/dts/anthropic-chat-model.d.ts +113 -0
- package/lib/dts/index.d.ts +1 -0
- package/lib/esm/anthropic-chat-model.d.ts +113 -0
- package/lib/esm/anthropic-chat-model.js +310 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/package.json +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.0.1...anthropic-v0.1.0) (2025-05-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **models:** publish model adapters as standalone packages ([#126](https://github.com/AIGNE-io/aigne-framework/issues/126)) ([588b8ae](https://github.com/AIGNE-io/aigne-framework/commit/588b8aea6abcee5fa87def1358bf51f84021c6ef))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/core bumped to 1.16.0
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @aigne/test-utils bumped to 0.3.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @aigne/anthropic
|
|
2
|
+
|
|
3
|
+
[](https://star-history.com/#AIGNE-io/aigne-framework)
|
|
4
|
+
[](https://github.com/AIGNE-io/aigne-framework/issues)
|
|
5
|
+
[](https://codecov.io/gh/AIGNE-io/aigne-framework)
|
|
6
|
+
[](https://www.npmjs.com/package/@aigne/anthropic)
|
|
7
|
+
[](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE.md)
|
|
8
|
+
|
|
9
|
+
**English** | [中文](README.zh.md)
|
|
10
|
+
|
|
11
|
+
AIGNE Anthropic SDK for integrating with Claude AI models within the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework).
|
|
12
|
+
|
|
13
|
+
## Introduction
|
|
14
|
+
|
|
15
|
+
`@aigne/anthropic` provides a seamless integration between the AIGNE Framework and Anthropic's Claude language models and API. This package enables developers to easily leverage Anthropic's Claude models in their AIGNE applications, providing a consistent interface across the framework while taking advantage of Claude's advanced AI capabilities.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
* **Anthropic API Integration**: Direct connection to Anthropic's API services using the official SDK
|
|
20
|
+
* **Chat Completions**: Support for Claude's chat completions API with all available models
|
|
21
|
+
* **Tool Calling**: Built-in support for Claude's tool calling capability
|
|
22
|
+
* **Streaming Responses**: Support for streaming responses for more responsive applications
|
|
23
|
+
* **Type-Safe**: Comprehensive TypeScript typings for all APIs and models
|
|
24
|
+
* **Consistent Interface**: Compatible with the AIGNE Framework's model interface
|
|
25
|
+
* **Error Handling**: Robust error handling and retry mechanisms
|
|
26
|
+
* **Full Configuration**: Extensive configuration options for fine-tuning behavior
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### Using npm
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @aigne/anthropic @aigne/core
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Using yarn
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
yarn add @aigne/anthropic @aigne/core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Using pnpm
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm add @aigne/anthropic @aigne/core
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Basic Usage
|
|
49
|
+
|
|
50
|
+
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model"
|
|
51
|
+
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
52
|
+
|
|
53
|
+
const model = new AnthropicChatModel({
|
|
54
|
+
// Provide API key directly or use environment variable ANTHROPIC_API_KEY or CLAUDE_API_KEY
|
|
55
|
+
apiKey: "your-api-key", // Optional if set in env variables
|
|
56
|
+
// Specify Claude model version (defaults to 'claude-3-7-sonnet-latest')
|
|
57
|
+
model: "claude-3-haiku-20240307",
|
|
58
|
+
// Configure model behavior
|
|
59
|
+
modelOptions: {
|
|
60
|
+
temperature: 0.7,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const result = await model.invoke({
|
|
65
|
+
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log(result);
|
|
69
|
+
/* Output:
|
|
70
|
+
{
|
|
71
|
+
text: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?",
|
|
72
|
+
model: "claude-3-haiku-20240307",
|
|
73
|
+
usage: {
|
|
74
|
+
inputTokens: 8,
|
|
75
|
+
outputTokens: 15
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
*/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Streaming Responses
|
|
82
|
+
|
|
83
|
+
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model-streaming-async-generator"
|
|
84
|
+
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
85
|
+
|
|
86
|
+
const model = new AnthropicChatModel({
|
|
87
|
+
apiKey: "your-api-key",
|
|
88
|
+
model: "claude-3-haiku-20240307",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const stream = await model.invoke(
|
|
92
|
+
{
|
|
93
|
+
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
94
|
+
},
|
|
95
|
+
undefined,
|
|
96
|
+
{ streaming: true },
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
let fullText = "";
|
|
100
|
+
const json = {};
|
|
101
|
+
|
|
102
|
+
for await (const chunk of stream) {
|
|
103
|
+
const text = chunk.delta.text?.text;
|
|
104
|
+
if (text) fullText += text;
|
|
105
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(fullText); // Output: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?"
|
|
109
|
+
console.log(json); // { model: "claude-3-haiku-20240307", usage: { inputTokens: 8, outputTokens: 15 } }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
Elastic-2.0
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @aigne/anthropic
|
|
2
|
+
|
|
3
|
+
[](https://star-history.com/#AIGNE-io/aigne-framework)
|
|
4
|
+
[](https://github.com/AIGNE-io/aigne-framework/issues)
|
|
5
|
+
[](https://codecov.io/gh/AIGNE-io/aigne-framework)
|
|
6
|
+
[](https://www.npmjs.com/package/@aigne/anthropic)
|
|
7
|
+
[](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE.md)
|
|
8
|
+
|
|
9
|
+
[English](README.md) | **中文**
|
|
10
|
+
|
|
11
|
+
AIGNE Anthropic SDK,用于在 [AIGNE 框架](https://github.com/AIGNE-io/aigne-framework) 中集成 Anthropic 的 Claude AI 模型。
|
|
12
|
+
|
|
13
|
+
## 简介
|
|
14
|
+
|
|
15
|
+
`@aigne/anthropic` 提供了 AIGNE 框架与 Anthropic 的 Claude 语言模型和 API 之间的无缝集成。该包使开发者能够在 AIGNE 应用程序中轻松利用 Anthropic 的 Claude 模型,同时提供框架内一致的接口,充分发挥 Claude 先进的 AI 能力。
|
|
16
|
+
|
|
17
|
+
## 特性
|
|
18
|
+
|
|
19
|
+
* **Anthropic API 集成**:使用官方 SDK 直接连接到 Anthropic 的 API 服务
|
|
20
|
+
* **聊天完成**:支持 Claude 的聊天完成 API 和所有可用模型
|
|
21
|
+
* **工具调用**:内置支持 Claude 的工具调用功能
|
|
22
|
+
* **流式响应**:支持流式响应,提供更高响应性的应用程序体验
|
|
23
|
+
* **类型安全**:为所有 API 和模型提供全面的 TypeScript 类型定义
|
|
24
|
+
* **一致接口**:兼容 AIGNE 框架的模型接口
|
|
25
|
+
* **错误处理**:健壮的错误处理和重试机制
|
|
26
|
+
* **完整配置**:丰富的配置选项用于微调行为
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
### 使用 npm
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @aigne/anthropic @aigne/core
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 使用 yarn
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
yarn add @aigne/anthropic @aigne/core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 使用 pnpm
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm add @aigne/anthropic @aigne/core
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 基本用法
|
|
49
|
+
|
|
50
|
+
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model"
|
|
51
|
+
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
52
|
+
|
|
53
|
+
const model = new AnthropicChatModel({
|
|
54
|
+
// Provide API key directly or use environment variable ANTHROPIC_API_KEY or CLAUDE_API_KEY
|
|
55
|
+
apiKey: "your-api-key", // Optional if set in env variables
|
|
56
|
+
// Specify Claude model version (defaults to 'claude-3-7-sonnet-latest')
|
|
57
|
+
model: "claude-3-haiku-20240307",
|
|
58
|
+
// Configure model behavior
|
|
59
|
+
modelOptions: {
|
|
60
|
+
temperature: 0.7,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const result = await model.invoke({
|
|
65
|
+
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log(result);
|
|
69
|
+
/* Output:
|
|
70
|
+
{
|
|
71
|
+
text: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?",
|
|
72
|
+
model: "claude-3-haiku-20240307",
|
|
73
|
+
usage: {
|
|
74
|
+
inputTokens: 8,
|
|
75
|
+
outputTokens: 15
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
*/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 流式响应
|
|
82
|
+
|
|
83
|
+
```typescript file="test/anthropic-chat-model.test.ts" region="example-anthropic-chat-model-streaming-async-generator"
|
|
84
|
+
import { AnthropicChatModel } from "@aigne/anthropic";
|
|
85
|
+
|
|
86
|
+
const model = new AnthropicChatModel({
|
|
87
|
+
apiKey: "your-api-key",
|
|
88
|
+
model: "claude-3-haiku-20240307",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const stream = await model.invoke(
|
|
92
|
+
{
|
|
93
|
+
messages: [{ role: "user", content: "Tell me about yourself" }],
|
|
94
|
+
},
|
|
95
|
+
undefined,
|
|
96
|
+
{ streaming: true },
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
let fullText = "";
|
|
100
|
+
const json = {};
|
|
101
|
+
|
|
102
|
+
for await (const chunk of stream) {
|
|
103
|
+
const text = chunk.delta.text?.text;
|
|
104
|
+
if (text) fullText += text;
|
|
105
|
+
if (chunk.delta.json) Object.assign(json, chunk.delta.json);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(fullText); // Output: "I'm Claude, an AI assistant created by Anthropic. How can I help you today?"
|
|
109
|
+
console.log(json); // { model: "claude-3-haiku-20240307", usage: { inputTokens: 8, outputTokens: 15 } }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 许可证
|
|
113
|
+
|
|
114
|
+
Elastic-2.0
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOptions, type ChatModelOutput } from "@aigne/core";
|
|
2
|
+
import { type PromiseOrValue } from "@aigne/core/utils/type-utils.js";
|
|
3
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for Claude Chat Model
|
|
7
|
+
*/
|
|
8
|
+
export interface AnthropicChatModelOptions {
|
|
9
|
+
/**
|
|
10
|
+
* API key for Anthropic's Claude API
|
|
11
|
+
*
|
|
12
|
+
* If not provided, will look for ANTHROPIC_API_KEY or CLAUDE_API_KEY in environment variables
|
|
13
|
+
*/
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Claude model to use
|
|
17
|
+
*
|
|
18
|
+
* Defaults to 'claude-3-7-sonnet-latest'
|
|
19
|
+
*/
|
|
20
|
+
model?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Additional model options to control behavior
|
|
23
|
+
*/
|
|
24
|
+
modelOptions?: ChatModelOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
*/
|
|
29
|
+
export declare const claudeChatModelOptionsSchema: z.ZodObject<{
|
|
30
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
31
|
+
model: z.ZodOptional<z.ZodString>;
|
|
32
|
+
modelOptions: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
model: z.ZodOptional<z.ZodString>;
|
|
34
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
parallelToolCalls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
parallelToolCalls: boolean;
|
|
41
|
+
model?: string | undefined;
|
|
42
|
+
temperature?: number | undefined;
|
|
43
|
+
topP?: number | undefined;
|
|
44
|
+
frequencyPenalty?: number | undefined;
|
|
45
|
+
presencePenalty?: number | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
model?: string | undefined;
|
|
48
|
+
temperature?: number | undefined;
|
|
49
|
+
topP?: number | undefined;
|
|
50
|
+
frequencyPenalty?: number | undefined;
|
|
51
|
+
presencePenalty?: number | undefined;
|
|
52
|
+
parallelToolCalls?: boolean | undefined;
|
|
53
|
+
}>>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
apiKey?: string | undefined;
|
|
56
|
+
model?: string | undefined;
|
|
57
|
+
modelOptions?: {
|
|
58
|
+
parallelToolCalls: boolean;
|
|
59
|
+
model?: string | undefined;
|
|
60
|
+
temperature?: number | undefined;
|
|
61
|
+
topP?: number | undefined;
|
|
62
|
+
frequencyPenalty?: number | undefined;
|
|
63
|
+
presencePenalty?: number | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
apiKey?: string | undefined;
|
|
67
|
+
model?: string | undefined;
|
|
68
|
+
modelOptions?: {
|
|
69
|
+
model?: string | undefined;
|
|
70
|
+
temperature?: number | undefined;
|
|
71
|
+
topP?: number | undefined;
|
|
72
|
+
frequencyPenalty?: number | undefined;
|
|
73
|
+
presencePenalty?: number | undefined;
|
|
74
|
+
parallelToolCalls?: boolean | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Implementation of the ChatModel interface for Anthropic's Claude API
|
|
79
|
+
*
|
|
80
|
+
* This model provides access to Claude's capabilities including:
|
|
81
|
+
* - Text generation
|
|
82
|
+
* - Tool use
|
|
83
|
+
* - JSON structured output
|
|
84
|
+
*
|
|
85
|
+
* Default model: 'claude-3-7-sonnet-latest'
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* Here's how to create and use a Claude chat model:
|
|
89
|
+
* {@includeCode ../test/anthropic-chat-model.test.ts#example-anthropic-chat-model}
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* Here's an example with streaming response:
|
|
93
|
+
* {@includeCode ../test/anthropic-chat-model.test.ts#example-anthropic-chat-model-streaming-async-generator}
|
|
94
|
+
*/
|
|
95
|
+
export declare class AnthropicChatModel extends ChatModel {
|
|
96
|
+
options?: AnthropicChatModelOptions | undefined;
|
|
97
|
+
constructor(options?: AnthropicChatModelOptions | undefined);
|
|
98
|
+
/**
|
|
99
|
+
* @hidden
|
|
100
|
+
*/
|
|
101
|
+
protected _client?: Anthropic;
|
|
102
|
+
get client(): Anthropic;
|
|
103
|
+
get modelOptions(): ChatModelOptions | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Process the input using Claude's chat model
|
|
106
|
+
* @param input - The input to process
|
|
107
|
+
* @returns The processed output from the model
|
|
108
|
+
*/
|
|
109
|
+
process(input: ChatModelInput): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
|
|
110
|
+
private _process;
|
|
111
|
+
private extractResultFromAnthropicStream;
|
|
112
|
+
private requestStructuredOutput;
|
|
113
|
+
}
|