Skip to content

Commit 9cafc95

Browse files
authored
docs(tarko): refactor agent options (#1596)
1 parent 2a6e0d9 commit 9cafc95

File tree

2 files changed

+95
-24
lines changed

2 files changed

+95
-24
lines changed

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

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ npm install @tarko/agent
3838
Create a `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

@@ -115,11 +120,16 @@ const agent = new Agent({
115120

116121
#### Agent Options
117122

123+
Based on the actual `AgentOptions` interface from the source code:
124+
118125
- `tools`: Array of tools available to the agent
119-
- `systemPrompt`: System prompt for the agent
120-
- `modelProvider`: Configuration for the LLM provider
121-
- `stream`: Enable streaming responses (default: false)
122-
- `maxIterations`: Maximum number of iterations (default: 10)
126+
- `instructions`: System prompt for the agent (not `systemPrompt`)
127+
- `model`: Model configuration (not `modelProvider`)
128+
- `maxIterations`: Maximum number of iterations (default: 1000, not 10)
129+
- `temperature`: LLM temperature (default: 0.7)
130+
- `maxTokens`: Token limit per request (default: 1000)
131+
- `toolCallEngine`: Tool call engine type ('native' | 'prompt_engineering' | 'structured_outputs')
132+
- `logLevel`: Log level for debugging
123133

124134
### Tool
125135

@@ -246,16 +256,17 @@ try {
246256
```ts
247257
const agent = new Agent({
248258
tools: [weatherTool, locationTool],
249-
systemPrompt: 'You are a helpful weather assistant.',
250-
modelProvider: {
259+
instructions: 'You are a helpful weather assistant.',
260+
model: {
261+
provider: 'openai',
262+
id: 'gpt-4o',
251263
apiKey: process.env.OPENAI_API_KEY,
252-
baseURL: 'https://api.openai.com/v1',
253-
model: 'gpt-4',
254-
temperature: 0.7,
255-
maxTokens: 1000,
256264
},
257-
maxIterations: 5,
258-
stream: true,
265+
temperature: 0.7,
266+
maxTokens: 1000,
267+
maxIterations: 20,
268+
toolCallEngine: 'native',
269+
logLevel: LogLevel.DEBUG,
259270
});
260271
```
261272

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

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ main();
8888
npx tsx index.ts
8989
```
9090

91+
输出:
92+
93+
```json
94+
{
95+
"id": "5c38c0a1-ccbe-48f0-8b97-ae78a4d9407e",
96+
"type": "assistant_message",
97+
"timestamp": 1750188571248,
98+
"content": "波士顿今天天气晴朗,温度为 70°F (21°C)。降水概率为 10%,湿度为 45%,风速为 5 mph。",
99+
"finishReason": "stop",
100+
"messageId": "msg_1750188570877_ics24k3x"
101+
}
102+
```
103+
91104
## API
92105

93106
### Agent
@@ -158,6 +171,64 @@ async function main() {
158171
- `tool_result`: 工具执行结果
159172
- `assistant_streaming_message`: 流式消息块
160173

174+
### 事件类型
175+
176+
#### AssistantMessage
177+
178+
```ts
179+
interface AssistantMessage {
180+
id: string;
181+
type: 'assistant_message';
182+
timestamp: number;
183+
content: string;
184+
toolCalls?: ToolCall[];
185+
finishReason: 'stop' | 'tool_calls' | 'length';
186+
messageId: string;
187+
}
188+
```
189+
190+
#### ToolCall
191+
192+
```ts
193+
interface ToolCallEvent {
194+
id: string;
195+
type: 'tool_call';
196+
timestamp: number;
197+
toolCallId: string;
198+
name: string;
199+
arguments: any;
200+
startTime: number;
201+
tool: ToolDefinition;
202+
}
203+
```
204+
205+
#### ToolResult
206+
207+
```ts
208+
interface ToolResult {
209+
id: string;
210+
type: 'tool_result';
211+
timestamp: number;
212+
toolCallId: string;
213+
name: string;
214+
content: any;
215+
elapsedMs: number;
216+
}
217+
```
218+
219+
#### StreamingMessage
220+
221+
```ts
222+
interface StreamingMessage {
223+
id: string;
224+
type: 'assistant_streaming_message';
225+
timestamp: number;
226+
content: string;
227+
isComplete: boolean;
228+
messageId: string;
229+
}
230+
```
231+
161232
### 错误处理
162233

163234
```ts
@@ -189,14 +260,3 @@ const agent = new Agent({
189260
```
190261

191262
更多高级使用模式,请参阅 [Agent Hooks 文档](/api/hooks)
192-
193-
## 即将推出
194-
195-
详细的 API 文档正在完善中,敬请期待:
196-
197-
- 完整的事件类型定义
198-
- 高级配置选项
199-
- 错误处理最佳实践
200-
- 性能优化指南
201-
202-
目前请参考 [英文版 Agent API 文档](/api/agent) 了解完整信息。

0 commit comments

Comments
 (0)