@@ -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
4343const locationTool = new Tool ({
4444 id: ' getCurrentLocation' ,
@@ -69,6 +69,11 @@ const weatherTool = new Tool({
6969});
7070
7171const 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 选项
117122
123+ 基于源码中实际的 ` AgentOptions ` 接口:
124+
118125- ` tools ` : Agent 可用的工具数组
119- - ` systemPrompt ` : Agent 的系统提示
120- - ` modelProvider ` : LLM 提供商的配置
121- - ` stream ` : 启用流式响应(默认: false)
122- - ` maxIterations ` : 最大迭代次数(默认: 10)
126+ - ` instructions ` : Agent 的系统提示(不是 ` systemPrompt ` )
127+ - ` model ` : Model 配置(不是 ` modelProvider ` )
128+ - ` maxIterations ` : 最大迭代次数(默认: 1000,不是 10)
129+ - ` temperature ` : LLM 温度(默认: 0.7)
130+ - ` maxTokens ` : 每次请求的 Token 限制(默认: 1000)
131+ - ` toolCallEngine ` : Tool 调用引擎类型('native' | 'prompt_engineering' | 'structured_outputs')
132+ - ` logLevel ` : 调试日志级别
123133
124134### Tool
125135
@@ -149,7 +159,7 @@ const locationTool = new Tool({
149159
150160### 流式模式
151161
152- 启用 ` stream: true ` :
162+ 在上面的基础示例中,如果启用 ` stream: true ` :
153163
154164``` ts
155165async function main() {
@@ -246,16 +256,17 @@ try {
246256``` ts
247257const agent = new Agent ({
248258 tools: [weatherTool , locationTool ],
249- systemPrompt: ' 你是一个有用的天气助手。' ,
250- modelProvider: {
259+ instructions: ' 你是一个有用的天气助手。' ,
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
0 commit comments