fix: 修复 NameError/状态污染/类型标注/统计; 补全练习与 main; 新增 config/.gitignore/requirements; 文档统一
This commit is contained in:
@@ -100,15 +100,6 @@ class SimpleAgentState(TypedDict, total=False):
|
||||
# 第三部分:定义 Tool 接口
|
||||
# ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@dataclass
|
||||
class ToolCall:
|
||||
"""工具调用的数据结构"""
|
||||
name: str # 工具名称
|
||||
arguments: dict # 传递给工具的参数
|
||||
result: Any = None # 工具执行结果
|
||||
error: str = None # 错误信息
|
||||
|
||||
|
||||
class BaseTool(ABC):
|
||||
"""
|
||||
工具基类(简化版,来自 Step 01)
|
||||
@@ -390,6 +381,9 @@ class SimpleAgent:
|
||||
status="input"
|
||||
)
|
||||
|
||||
# 对话轮次计数器
|
||||
self.round_count = 0
|
||||
|
||||
def reset(self):
|
||||
"""重置 Agent 状态"""
|
||||
self.state = SimpleAgentState(
|
||||
@@ -454,6 +448,8 @@ class SimpleAgent:
|
||||
"content": user_input
|
||||
})
|
||||
self.state["status"] = "thinking"
|
||||
self.state["tool_result"] = None
|
||||
self.round_count += 1
|
||||
|
||||
# 2. 大脑决定行动
|
||||
decision = self.brain.decide(self.state)
|
||||
|
||||
Reference in New Issue
Block a user