Skip to content

Commit df2ae59

Browse files
authored
docs(tarko): sync zh agent api docs with en version (#1600)
1 parent 9cafc95 commit df2ae59

File tree

1 file changed

+23
-14
lines changed
  • multimodal/websites/tarko/docs/zh/api

1 file changed

+23
-14
lines changed

multimodal/websites/tarko/docs/zh/api/agent.mdx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ npm install @tarko/agent
3838
创建 `index.ts`
3939

4040
```ts
41-
import { Agent, Tool, z } from '@tarko/agent';
41+
import { Agent, Tool, z, LogLevel } from '@tarko/agent';
4242

4343
const locationTool = new Tool({
4444
id: 'getCurrentLocation',
@@ -69,6 +69,11 @@ const weatherTool = new Tool({
6969
});
7070

7171
const agent = new Agent({
72+
model: {
73+
provider: 'openai',
74+
id: 'gpt-4o',
75+
apiKey: process.env.OPENAI_API_KEY,
76+
},
7277
tools: [locationTool, weatherTool],
7378
});
7479

@@ -116,10 +121,13 @@ const agent = new Agent({
116121
#### Agent 选项
117122

118123
- `tools`: Agent 可用的工具数组
119-
- `systemPrompt`: Agent 的系统提示
120-
- `modelProvider`: LLM 提供商的配置
121-
- `stream`: 启用流式响应(默认: false)
122-
- `maxIterations`: 最大迭代次数(默认: 10)
124+
- `instructions`: Agent 的系统提示(不是 `systemPrompt`
125+
- `model`: Model 配置(不是 `modelProvider`
126+
- `maxIterations`: 最大迭代次数(默认: 1000,不是 10)
127+
- `temperature`: LLM 温度(默认: 0.7)
128+
- `maxTokens`: 每次请求的 Token 限制(默认: 1000)
129+
- `toolCallEngine`: 工具调用引擎类型('native' | 'prompt_engineering' | 'structured_outputs')
130+
- `logLevel`: 调试的日志级别
123131

124132
### Tool
125133

@@ -149,7 +157,7 @@ const locationTool = new Tool({
149157

150158
### 流式模式
151159

152-
启用 `stream: true`
160+
在上面的基础示例中,如果你启用 `stream: true`
153161

154162
```ts
155163
async function main() {
@@ -246,16 +254,17 @@ try {
246254
```ts
247255
const agent = new Agent({
248256
tools: [weatherTool, locationTool],
249-
systemPrompt: '你是一个有用的天气助手。',
250-
modelProvider: {
257+
instructions: '你是一个有用的天气助手。',
258+
model: {
259+
provider: 'openai',
260+
id: 'gpt-4o',
251261
apiKey: process.env.OPENAI_API_KEY,
252-
baseURL: 'https://api.openai.com/v1',
253-
model: 'gpt-4',
254-
temperature: 0.7,
255-
maxTokens: 1000,
256262
},
257-
maxIterations: 5,
258-
stream: true,
263+
temperature: 0.7,
264+
maxTokens: 1000,
265+
maxIterations: 20,
266+
toolCallEngine: 'native',
267+
logLevel: LogLevel.DEBUG,
259268
});
260269
```
261270

0 commit comments

Comments
 (0)