集成新的Beaver后端服务到应用实例中,替换原有的nanobot实现。 主要变更包括: - 在Dockerfile和环境配置中添加Beaver相关路径和配置变量 - 更新工作目录结构从.nanobot到.beaver - 实现Beaver引擎加载器,支持配置文件加载和工具组装 - 添加内置工具如ListDirectoryTool、ReadFileTool、SearchFilesTool - 更新消息处理流程,支持通道适配器和网关模式 - 重构技能系统,支持显式工具提示和嵌入式检索 - 改进错误处理和生命周期管理 此变更使应用实例能够使用统一的Beaver后端进行AI代理运行时管理。
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""最小调试工具:把输入原样回显。
|
|
|
|
它的价值不是业务能力,而是运行时验证:
|
|
当你只想确认 tool loop 是否能走通时,`echo` 是最便宜、最确定的测试工具。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
|
|
ECHO_TOOL_DESCRIPTION = "Echo the provided text back to the agent. Useful for verifying tool calling."
|
|
|
|
ECHO_TOOL_PARAMETERS: dict[str, Any] = {
|
|
"type": "object",
|
|
"properties": {
|
|
"text": {
|
|
"type": "string",
|
|
"description": "The text to echo back.",
|
|
}
|
|
},
|
|
"required": ["text"],
|
|
}
|
|
|
|
|
|
def echo_tool(*, text: str) -> str:
|
|
return text
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class EchoTool:
|
|
"""面向 runtime 的最小内建工具。"""
|
|
|
|
name: str = "echo"
|
|
description: str = ECHO_TOOL_DESCRIPTION
|
|
toolset: str = "debug"
|
|
always_available: bool = False
|
|
parameters: dict[str, Any] = field(default_factory=lambda: dict(ECHO_TOOL_PARAMETERS))
|
|
|
|
async def execute(self, **kwargs: Any) -> str:
|
|
text = kwargs.get("text")
|
|
if not isinstance(text, str):
|
|
raise ValueError("echo tool requires a string field 'text'")
|
|
return echo_tool(text=text)
|