mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
update:优化工具回复
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""基础工具定义模块"""
|
||||
|
||||
from .tool_types import ToolType, ToolAction, ToolResult, ToolDefinition
|
||||
from .tool_types import ToolType, ToolDefinition
|
||||
from .tool_executor import ToolExecutor
|
||||
|
||||
__all__ = ["ToolType", "ToolAction", "ToolResult", "ToolDefinition", "ToolExecutor"]
|
||||
__all__ = ["ToolType", "ToolDefinition", "ToolExecutor"]
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Any
|
||||
from .tool_types import ToolDefinition, ToolResult
|
||||
from .tool_types import ToolDefinition
|
||||
from plugins_func.register import ActionResponse
|
||||
|
||||
|
||||
class ToolExecutor(ABC):
|
||||
@@ -11,7 +12,7 @@ class ToolExecutor(ABC):
|
||||
@abstractmethod
|
||||
async def execute(
|
||||
self, conn, tool_name: str, arguments: Dict[str, Any]
|
||||
) -> ToolResult:
|
||||
) -> ActionResponse:
|
||||
"""执行工具调用"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""工具系统的类型定义"""
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, Optional, Callable, Awaitable
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Dict, Optional
|
||||
from plugins_func.register import Action
|
||||
|
||||
|
||||
class ToolType(Enum):
|
||||
@@ -15,26 +16,6 @@ class ToolType(Enum):
|
||||
DEVICE_MCP = "device_mcp" # 设备端MCP
|
||||
|
||||
|
||||
class ToolAction(Enum):
|
||||
"""工具执行后的动作类型"""
|
||||
|
||||
ERROR = "error" # 错误
|
||||
NOT_FOUND = "not_found" # 工具未找到
|
||||
RESPONSE = "response" # 直接回复
|
||||
REQUEST_LLM = "request_llm" # 需要LLM处理
|
||||
NONE = "none" # 无需特殊处理
|
||||
|
||||
|
||||
@dataclass
|
||||
class ToolResult:
|
||||
"""工具执行结果"""
|
||||
|
||||
action: ToolAction
|
||||
content: str # 结果内容
|
||||
response: Optional[str] = None # 直接回复内容
|
||||
error: Optional[str] = None # 错误信息
|
||||
|
||||
|
||||
@dataclass
|
||||
class ToolDefinition:
|
||||
"""工具定义"""
|
||||
|
||||
Reference in New Issue
Block a user