autocoder-nano 0.1.25__py3-none-any.whl → 0.1.27__py3-none-any.whl
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.
- autocoder_nano/agent/agent_base.py +376 -63
- autocoder_nano/auto_coder_nano.py +147 -1842
- autocoder_nano/edit/__init__.py +20 -0
- autocoder_nano/edit/actions.py +136 -0
- autocoder_nano/edit/code/__init__.py +0 -0
- autocoder_nano/edit/code/generate_editblock.py +403 -0
- autocoder_nano/edit/code/merge_editblock.py +418 -0
- autocoder_nano/edit/code/modification_ranker.py +90 -0
- autocoder_nano/edit/text.py +38 -0
- autocoder_nano/index/__init__.py +0 -0
- autocoder_nano/index/entry.py +166 -0
- autocoder_nano/index/index_manager.py +410 -0
- autocoder_nano/index/symbols_utils.py +43 -0
- autocoder_nano/llm_types.py +12 -8
- autocoder_nano/version.py +1 -1
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/METADATA +1 -1
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/RECORD +21 -10
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/LICENSE +0 -0
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/WHEEL +0 -0
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/entry_points.txt +0 -0
- {autocoder_nano-0.1.25.dist-info → autocoder_nano-0.1.27.dist-info}/top_level.txt +0 -0
@@ -1,33 +1,88 @@
|
|
1
|
+
import random
|
2
|
+
import time
|
1
3
|
from abc import ABC, abstractmethod
|
2
|
-
from
|
4
|
+
from collections import deque
|
5
|
+
from datetime import datetime
|
6
|
+
from typing import Dict, List, Any, Deque, Union
|
7
|
+
|
8
|
+
from loguru import logger
|
9
|
+
from pydantic import BaseModel
|
10
|
+
|
11
|
+
from autocoder_nano.llm_prompt import prompt
|
12
|
+
from autocoder_nano.llm_client import AutoLLM
|
13
|
+
|
14
|
+
|
15
|
+
# -------------------- 基础数据模型 --------------------
|
16
|
+
|
17
|
+
|
18
|
+
class AgentMemoryItem(BaseModel):
|
19
|
+
step_id: int = 0 # 步骤标识
|
20
|
+
action: str
|
21
|
+
parameters: Dict[str, Any]
|
22
|
+
result: Dict[str, Any] # 结果改为结构化字典
|
23
|
+
output_fields: List[str] # 改为列表类型, 存储提取的关键字段
|
24
|
+
timestamp: datetime = datetime.now()
|
25
|
+
|
26
|
+
|
27
|
+
class DecisionContext(BaseModel):
|
28
|
+
"""决策上下文数据模型"""
|
29
|
+
user_input: str
|
30
|
+
history: List[tuple]
|
31
|
+
memory: List[AgentMemoryItem]
|
32
|
+
context_vars: Dict[str, Any] = {} # 新增上下文变量存储
|
33
|
+
|
34
|
+
|
35
|
+
class SingleTool(BaseModel):
|
36
|
+
""" 单个工具 """
|
37
|
+
action: str
|
38
|
+
parameters: Dict[str, Union[str, Dict[str, Any]]] # 修改为支持嵌套结构
|
39
|
+
reasoning: str
|
40
|
+
output_fields: List[str] = [] # 设置为可选,默认空列表
|
41
|
+
|
42
|
+
|
43
|
+
class ToolChain(BaseModel):
|
44
|
+
""" 工具链 """
|
45
|
+
tools: List[SingleTool]
|
46
|
+
|
47
|
+
|
48
|
+
# -------------------- 工具基类 --------------------
|
3
49
|
|
4
50
|
|
5
51
|
class BaseTool:
|
6
|
-
"""工具基类抽象"""
|
7
|
-
|
8
|
-
|
9
|
-
self.
|
10
|
-
self.
|
52
|
+
""" 工具基类抽象 """
|
53
|
+
|
54
|
+
def __init__(self, name: str, description: str, input_parameters: str, output_parameters: str):
|
55
|
+
self.name = name # 工具名称
|
56
|
+
self.description = description # 工具描述
|
57
|
+
self.input_parameters = input_parameters
|
58
|
+
self.output_parameters = output_parameters
|
59
|
+
# self.parameters = parameters # 工具参数
|
11
60
|
|
12
61
|
@abstractmethod
|
13
|
-
def execute(self, **kwargs) ->
|
14
|
-
"""
|
62
|
+
def execute(self, **kwargs) -> Dict:
|
63
|
+
""" 工具执行方法(由继承类实现) """
|
15
64
|
pass
|
16
65
|
|
17
66
|
|
67
|
+
# -------------------- Agent基类 --------------------
|
68
|
+
|
69
|
+
|
18
70
|
class BaseAgent(ABC):
|
19
|
-
"""Agent基类抽象"""
|
71
|
+
""" Agent基类抽象 """
|
72
|
+
|
20
73
|
def __init__(self):
|
21
74
|
self.tools: Dict[str, BaseTool] = {} # 可用工具注册表
|
22
|
-
self.
|
23
|
-
self.
|
75
|
+
self.short_term_memory: Deque[AgentMemoryItem] = deque(maxlen=100) # 短期记忆
|
76
|
+
self.long_term_memory: List[AgentMemoryItem] = [] # 长期记忆
|
77
|
+
self.history: List[tuple] = [] # 交互历史
|
78
|
+
self.step_counter = 0 # 新增步骤计数器
|
24
79
|
|
25
80
|
def register_tool(self, tool: BaseTool):
|
26
81
|
"""注册工具到Agent"""
|
27
82
|
self.tools[tool.name] = tool
|
28
83
|
|
29
84
|
@abstractmethod
|
30
|
-
def decide_next_action(self,
|
85
|
+
def decide_next_action(self, context: DecisionContext) -> ToolChain:
|
31
86
|
"""
|
32
87
|
决策核心(需要子类实现)
|
33
88
|
返回结构示例:
|
@@ -39,89 +94,347 @@ class BaseAgent(ABC):
|
|
39
94
|
"""
|
40
95
|
pass
|
41
96
|
|
42
|
-
def execute_tool(self, tool_name: str, parameters: Dict) ->
|
43
|
-
"""
|
97
|
+
def execute_tool(self, tool_name: str, parameters: Dict, context_vars: Dict) -> Dict:
|
98
|
+
""" 同步执行工具(新增context_vars参数)"""
|
99
|
+
return self.execute_tool_async(tool_name, parameters, context_vars)
|
100
|
+
|
101
|
+
def execute_tool_async(self, tool_name: str, parameters: Dict, context_vars: Dict):
|
102
|
+
"""执行工具并处理异常(新增context_vars参数)"""
|
44
103
|
try:
|
45
104
|
tool = self.tools.get(tool_name)
|
46
105
|
if not tool:
|
47
|
-
return
|
48
|
-
|
106
|
+
return {"error": f"Tool {tool_name} not found"}
|
107
|
+
|
108
|
+
# 参数预处理(替换上下文变量)
|
109
|
+
processed_params = {}
|
110
|
+
for k, v in parameters.items():
|
111
|
+
if isinstance(v, str) and v.startswith("ctx."):
|
112
|
+
var_name = v[4:]
|
113
|
+
processed_params[k] = context_vars.get(var_name, v)
|
114
|
+
# processed_params[k] = var_name.format(**context_vars)
|
115
|
+
else:
|
116
|
+
processed_params[k] = v
|
117
|
+
|
118
|
+
return tool.execute(**processed_params)
|
49
119
|
except Exception as e:
|
50
|
-
return f"Error executing {tool_name}: {str(e)}"
|
120
|
+
return {"error": f"Error executing {tool_name}: {str(e)}"}
|
121
|
+
|
122
|
+
@staticmethod
|
123
|
+
def should_persist(memory_item: AgentMemoryItem) -> bool:
|
124
|
+
"""简单判断是否需要持久化到长期记忆"""
|
125
|
+
# 这里简单实现:随机决定是否持久化
|
126
|
+
return random.random() > 0.7
|
51
127
|
|
52
128
|
def process_request(self, user_input: str) -> str:
|
53
|
-
"""
|
54
|
-
处理请求的主流程:
|
55
|
-
1. 接收用户输入
|
56
|
-
2. 决策循环
|
57
|
-
3. 执行工具
|
58
|
-
4. 整合结果
|
59
|
-
"""
|
60
129
|
self.history.append(("user", user_input))
|
130
|
+
logger.info(f"正在处理需求: {user_input}")
|
61
131
|
|
62
|
-
#
|
132
|
+
# 初始化上下文变量
|
133
|
+
context_vars = {}
|
63
134
|
final_response = None
|
64
|
-
max_steps = 5 # 防止无限循环
|
65
135
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
136
|
+
# 构建决策上下文
|
137
|
+
context = DecisionContext(
|
138
|
+
user_input=user_input,
|
139
|
+
history=self.history,
|
140
|
+
memory=list(self.short_term_memory) + self.long_term_memory,
|
141
|
+
context_vars=context_vars
|
142
|
+
)
|
143
|
+
|
144
|
+
# 获取完整工具链
|
145
|
+
decision_chain = self.decide_next_action(context)
|
146
|
+
logger.info(f"工具链总共有 {len(decision_chain.tools)} 步")
|
147
|
+
logger.info("依次使用以下工具: ")
|
148
|
+
for decision in decision_chain.tools:
|
149
|
+
logger.info(f"{decision.action}: {decision.reasoning}")
|
72
150
|
|
73
|
-
|
74
|
-
|
151
|
+
# 执行工具链
|
152
|
+
for decision in decision_chain.tools:
|
153
|
+
self.step_counter += 1
|
154
|
+
logger.info(f"正在执行: {self.step_counter}/{len(decision_chain.tools)}")
|
75
155
|
|
76
|
-
if decision
|
77
|
-
final_response = decision
|
156
|
+
if decision.action == "final_answer":
|
157
|
+
final_response = decision.parameters["input"]
|
158
|
+
# 处理上下文变量引用
|
159
|
+
if final_response.startswith("ctx."):
|
160
|
+
final_response = context_vars.get(final_response[4:], final_response)
|
78
161
|
break
|
79
162
|
|
80
163
|
# 执行工具
|
81
164
|
tool_result = self.execute_tool(
|
82
|
-
decision
|
83
|
-
decision
|
165
|
+
decision.action,
|
166
|
+
decision.parameters,
|
167
|
+
context_vars
|
168
|
+
)
|
169
|
+
|
170
|
+
# 更新上下文变量
|
171
|
+
# if "output_fields" in decision:
|
172
|
+
for field in decision.output_fields:
|
173
|
+
if field in tool_result:
|
174
|
+
context_vars[field] = tool_result[field]
|
175
|
+
|
176
|
+
# 记录记忆
|
177
|
+
memory_item = AgentMemoryItem(
|
178
|
+
step_id=self.step_counter,
|
179
|
+
action=decision.action,
|
180
|
+
parameters=decision.parameters,
|
181
|
+
result=tool_result,
|
182
|
+
output_fields=decision.output_fields # 确保传入列表
|
84
183
|
)
|
184
|
+
self.short_term_memory.append(memory_item)
|
185
|
+
if self.should_persist(memory_item):
|
186
|
+
self.long_term_memory.append(memory_item)
|
85
187
|
|
86
|
-
|
87
|
-
self.memory.append({
|
88
|
-
"action": decision["action"],
|
89
|
-
"result": tool_result
|
90
|
-
})
|
188
|
+
logger.info("工具链执行完毕")
|
91
189
|
|
92
190
|
return final_response or "Unable to generate valid response"
|
93
191
|
|
94
192
|
|
193
|
+
# -------------------- 具体工具实现 --------------------
|
194
|
+
|
195
|
+
|
196
|
+
class GenerateSQL(BaseTool):
|
197
|
+
def __init__(self):
|
198
|
+
super().__init__(
|
199
|
+
name="generate_sql",
|
200
|
+
description="基于用户的需求生成对应的数据查询sql",
|
201
|
+
input_parameters="`input`: str 类型, 用户需求",
|
202
|
+
output_parameters="`output`: str 类型,基于用户需求生成对应的数据库查询sql"
|
203
|
+
# parameters={"intput": str}
|
204
|
+
)
|
205
|
+
|
206
|
+
def execute(self, **kwargs) -> Dict:
|
207
|
+
query = kwargs.get("input", "")
|
208
|
+
time.sleep(0.2)
|
209
|
+
return {"output": f"分析 {query} :select * from table limit 100;"}
|
210
|
+
|
211
|
+
|
212
|
+
class QueryData(BaseTool):
|
213
|
+
def __init__(self):
|
214
|
+
super().__init__(
|
215
|
+
name="query_data",
|
216
|
+
description="基于sql去数据库中查询数据",
|
217
|
+
input_parameters="`input`: str 类型, 用于查询数据库的 sql 语句",
|
218
|
+
output_parameters="`output`: str 类型,基于 sql 查询出来的数据"
|
219
|
+
# parameters={"input": str}
|
220
|
+
)
|
221
|
+
|
222
|
+
def execute(self, **kwargs) -> Dict:
|
223
|
+
sql = kwargs.get("input", "")
|
224
|
+
time.sleep(0.2)
|
225
|
+
return {"output": f"基于 {sql}, 返回数据: 1234567890"}
|
226
|
+
|
227
|
+
|
228
|
+
class AnalysisData(BaseTool):
|
229
|
+
def __init__(self):
|
230
|
+
super().__init__(
|
231
|
+
name="analysis_data",
|
232
|
+
description="分析查询的数据",
|
233
|
+
input_parameters="`input`: str 类型, 从数据库中查询到的数据",
|
234
|
+
output_parameters="`output`: str 类型,数据分析结果"
|
235
|
+
# parameters={"input": str}
|
236
|
+
)
|
237
|
+
|
238
|
+
def execute(self, **kwargs) -> Dict:
|
239
|
+
data = kwargs.get("input", "")
|
240
|
+
time.sleep(0.2)
|
241
|
+
return {"output": f"分析 {data} 数据, 该数据正常"}
|
242
|
+
|
243
|
+
|
244
|
+
# -------------------- 示例Agent实现 --------------------
|
245
|
+
|
246
|
+
|
95
247
|
class ExampleAgent(BaseAgent):
|
96
|
-
"""
|
97
|
-
|
248
|
+
""" 可运行的demo实现,模拟大模型决策 """
|
249
|
+
|
250
|
+
def __init__(self, llm: AutoLLM):
|
251
|
+
super().__init__()
|
252
|
+
self.llm = llm
|
253
|
+
|
254
|
+
@prompt()
|
255
|
+
def _example_prompt(self, context: DecisionContext, tools: Dict[str, BaseTool]):
|
256
|
+
"""
|
257
|
+
## 角色定义
|
258
|
+
您是 Auto-Coder 团队开发的顶级AI助手 Auto-Coder,定位为全能型智能体,需主动思考并综合运用工具链解决复杂问题
|
259
|
+
|
260
|
+
## 核心能力
|
261
|
+
1. 信息处理专家 - 支持多语言文档分析/数据清洗/知识图谱构建
|
262
|
+
2. 代码工程师 - 全栈开发/自动化脚本/数据处理程序编写
|
263
|
+
3. 研究助手 - 文献综述/数据分析/可视化报告生成
|
264
|
+
4. 问题解决专家 - 分步拆解复杂问题,通过工具组合实现目标
|
265
|
+
|
266
|
+
## 工作流程
|
267
|
+
1. 输入解析:
|
268
|
+
a. 识别用户真实需求,区分任务类型(查询/计算/编程/研究等)
|
269
|
+
2. 上下文查看:
|
270
|
+
a. 分析记忆库中的相关记录
|
271
|
+
b. 检索历史交互记录
|
272
|
+
c. 确认当前执行目标
|
273
|
+
3. 工具决策:
|
274
|
+
a. 严格遵循工具调用模式, 确保提供所有必要参数, 以及确保参数类型/格式/单位的正确
|
275
|
+
b. 绝不调用未列出的工具
|
276
|
+
c. 优先选择耗时最短的工具链组合(即仅在必要时调用工具)
|
277
|
+
d. 调用工具需向用户说明原因(20字以内说明即可)
|
278
|
+
4. 结果处理:
|
279
|
+
a. 验证工具返回数据的有效性
|
280
|
+
b. 自动修正异常值/格式错误
|
281
|
+
|
282
|
+
## 工具调用规范 [严格模式]
|
283
|
+
1. 参数校验: 缺失参数时直接结束调用链生成,禁止猜测参数值,并且说明具体缺失内容
|
284
|
+
2. 工具组合: 单个需求决策最多使用 5 个工具种类,如果 5 个工具种类无法解决这个需求, 直接结束调用链生成, 并且说明原因
|
285
|
+
3. 工具链长度: 单个需求的工具链组合最多不超过 10 个, 避免长依赖链, 如果 10 个步骤无法解决这个需求, 直接结束调用链生成, 并且说明原因
|
286
|
+
|
287
|
+
## 交互协议
|
288
|
+
1. 语言策略:
|
289
|
+
a. 默认使用中文交互
|
290
|
+
b. 代码块/技术参数/工具名称 保持英文
|
291
|
+
c. 专业术语首次出现时附加中文注释
|
292
|
+
2. 成功响应标准:
|
293
|
+
a. 在要求的工具种类数量, 以及工具链长度下, 可以顺利完成用户需求时, 为成功响应, 正常返回工具链即可
|
294
|
+
3. 失败响应标准:
|
295
|
+
a. 缺失参数时直接结束调用链生成, 为失败响应
|
296
|
+
b. 5 个工具种类无法解决这个需求时直接结束调用链生成, 为失败响应
|
297
|
+
c. 10 个步骤无法解决这个需求时直接结束调用链生成, 为失败响应
|
298
|
+
4. 风格要求:
|
299
|
+
a. 保持专业但友好的语气
|
300
|
+
b. 避免使用Markdown格式
|
301
|
+
|
302
|
+
## 以下是一个正常生成工具链的示例需求
|
303
|
+
原始需求:我要分析xxx数据
|
304
|
+
|
305
|
+
工具列表
|
306
|
+
工具名称: generate_sql
|
307
|
+
工具描述: 基于用户的需求生成对应的数据查询sql
|
308
|
+
参数说明:
|
309
|
+
- `input`: str 类型, 用户的查询需求
|
310
|
+
返回值:
|
311
|
+
- `output`: str 类型,根据用户需求生成的数据库查询 sql 语句
|
312
|
+
----------------------------------
|
313
|
+
工具名称: query_data
|
314
|
+
工具描述: 基于sql去数据库中查询数据
|
315
|
+
参数说明:
|
316
|
+
- `input`: str 类型, 用于查询数据库的 sql 语句
|
317
|
+
返回值:
|
318
|
+
- `output`: str 类型,基于 sql 查询出来的数据
|
319
|
+
----------------------------------
|
320
|
+
工具名称: analysis_data
|
321
|
+
工具描述: 分析查询的数据
|
322
|
+
参数说明:
|
323
|
+
- `input`: str 类型, 用于查询数据库的 sql 语句
|
324
|
+
返回值:
|
325
|
+
- `output`: str 类型,基于 sql 查询出来的数据
|
326
|
+
|
327
|
+
工具链正常返回示例
|
328
|
+
```
|
329
|
+
{
|
330
|
+
"tools": [
|
331
|
+
{
|
332
|
+
"action": "generate_sql",
|
333
|
+
"parameters": {"input": user_input},
|
334
|
+
"reasoning": "基于用户的需求生成对应的数据查询sql",
|
335
|
+
"output_fields": ["output"]
|
336
|
+
},
|
337
|
+
{
|
338
|
+
"action": "query_data",
|
339
|
+
"parameters": {"input": "ctx.output"},
|
340
|
+
"reasoning": "基于sql去数据库中查询数据",
|
341
|
+
"output_fields": ["output"]
|
342
|
+
},
|
343
|
+
{
|
344
|
+
"action": "analysis_data",
|
345
|
+
"parameters": {"input": "ctx.output"},
|
346
|
+
"reasoning": "分析查询的数据",
|
347
|
+
"output_fields": ["output"]
|
348
|
+
},
|
349
|
+
{
|
350
|
+
"action": "final_answer",
|
351
|
+
"parameters": {"input": "ctx.output"},
|
352
|
+
"reasoning": "输出最终结果",
|
353
|
+
"output_fields": []
|
354
|
+
}
|
355
|
+
]
|
356
|
+
}
|
357
|
+
```
|
358
|
+
|
359
|
+
工具链异常返回示例
|
360
|
+
```
|
361
|
+
{
|
362
|
+
"tools": [
|
363
|
+
{
|
364
|
+
"action": "final_answer",
|
365
|
+
"parameters": {"input": ""},
|
366
|
+
"reasoning": "工具链生成异常原因",
|
367
|
+
"output_fields": []
|
368
|
+
}
|
369
|
+
]
|
370
|
+
}
|
371
|
+
```
|
372
|
+
|
373
|
+
返回说明:
|
374
|
+
1. 请严格按格式要求返回结果, 无需额外的说明
|
375
|
+
2. action 字段表示你决定选用的工具名称, 如果是最后一个步骤, 填写 'final_answer'
|
376
|
+
3. parameters 字段表示输入参数, 字段名称固定使用 'input',
|
377
|
+
a. 如果是首个工具调用, 直接填充用户需求, 即 {"input": "用户需求"}
|
378
|
+
b. 第二个之后的工具调用, 填充 'ctx.output' , 即 {"input": "ctx.output"}
|
379
|
+
c. 如果是调用链生成失败, 填充空字符串, 即 {"input": ""}
|
380
|
+
2. reasoning 字段表示你选用这个工具的原因 或者 工具链生成异常原因, 20字以内说明即可
|
381
|
+
3. output_fields 字段表示输出的字段,字段名称固定使用 'output', 如果 'action' 为 'final_answer', 填写 [] 即可
|
382
|
+
|
383
|
+
## 正式需求决策上下文
|
384
|
+
|
385
|
+
用户需求: {{ context.user_input }}
|
386
|
+
|
387
|
+
交互历史:
|
388
|
+
{% for his in context.history %}
|
389
|
+
{{ his }}
|
390
|
+
{% endfor %}
|
391
|
+
|
392
|
+
记忆Memory系统: {}
|
393
|
+
|
394
|
+
工具列表:
|
395
|
+
{% for key, value in tools.items() %}
|
396
|
+
工具名称: {{ key }}
|
397
|
+
工具描述: {{ value.description }}
|
398
|
+
参数说明:
|
399
|
+
- {{ value.input_parameters }}
|
400
|
+
返回值:
|
401
|
+
- {{ value.output_parameters }}
|
402
|
+
----------------------------------
|
403
|
+
{% endfor %}
|
404
|
+
|
405
|
+
接下来请生成工具链
|
406
|
+
"""
|
407
|
+
|
408
|
+
def decide_next_action(self, context: DecisionContext) -> ToolChain:
|
98
409
|
"""
|
99
410
|
伪代码实现:
|
100
411
|
- 调用大模型API
|
101
412
|
- 解析返回的JSON
|
102
413
|
- 返回决策字典
|
103
414
|
"""
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
415
|
+
llm = self.llm
|
416
|
+
llm.setup_default_model_name('chat_model')
|
417
|
+
tools = self._example_prompt.with_llm(self.llm).with_return_type(ToolChain).run(context, self.tools)
|
418
|
+
|
419
|
+
return tools
|
420
|
+
|
421
|
+
|
422
|
+
# -------------------- 使用示例 --------------------
|
110
423
|
|
111
424
|
|
112
425
|
# 使用示例
|
113
426
|
if __name__ == "__main__":
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
description="网络搜索工具",
|
121
|
-
parameters={"query": str}
|
427
|
+
auto_llm = AutoLLM()
|
428
|
+
auto_llm.setup_sub_client(
|
429
|
+
"chat_model",
|
430
|
+
"",
|
431
|
+
"https://ark.cn-beijing.volces.com/api/v3",
|
432
|
+
"deepseek-v3-250324"
|
122
433
|
)
|
123
|
-
agent
|
434
|
+
agent = ExampleAgent(auto_llm)
|
435
|
+
agent.register_tool(GenerateSQL())
|
436
|
+
agent.register_tool(QueryData())
|
437
|
+
agent.register_tool(AnalysisData())
|
124
438
|
|
125
|
-
|
126
|
-
|
127
|
-
print(response)
|
439
|
+
response = agent.process_request("我要分析xxx数据")
|
440
|
+
# print(f"系统响应:{response}")
|