From 17b521796c3c2c047301449aff12de348caf2c60 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Mon, 18 May 2026 23:53:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E5=BA=9F?= =?UTF-8?q?=E5=BC=83=E7=9A=84=20calculator=20=E5=86=85=E7=BD=AE=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 计算器功能已不再需要,移除相关代码以简化工具集。 Co-authored-by: xerrors --- .../yuxi/agents/toolkits/buildin/__init__.py | 3 +-- .../yuxi/agents/toolkits/buildin/tools.py | 21 ------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/backend/package/yuxi/agents/toolkits/buildin/__init__.py b/backend/package/yuxi/agents/toolkits/buildin/__init__.py index eed55251..7f5f525b 100644 --- a/backend/package/yuxi/agents/toolkits/buildin/__init__.py +++ b/backend/package/yuxi/agents/toolkits/buildin/__init__.py @@ -1,10 +1,9 @@ # buildin 工具包 from .install_skill import install_skill -from .tools import ask_user_question, calculator, present_artifacts, text_to_img_qwen_image +from .tools import ask_user_question, present_artifacts, text_to_img_qwen_image __all__ = [ "ask_user_question", - "calculator", "install_skill", "present_artifacts", "text_to_img_qwen_image", diff --git a/backend/package/yuxi/agents/toolkits/buildin/tools.py b/backend/package/yuxi/agents/toolkits/buildin/tools.py index 3c107e2d..7fac31ea 100644 --- a/backend/package/yuxi/agents/toolkits/buildin/tools.py +++ b/backend/package/yuxi/agents/toolkits/buildin/tools.py @@ -110,27 +110,6 @@ def _normalize_presented_artifact_path(filepath: str, runtime: ToolRuntime) -> s return f"{outputs_virtual_prefix}/{relative_path.as_posix()}" -@tool(category="buildin", tags=["计算"], display_name="计算器") -def calculator(a: float, b: float, operation: str) -> float: - """计算器:对给定的2个数字进行基本数学运算""" - try: - if operation == "add": - return a + b - elif operation == "subtract": - return a - b - elif operation == "multiply": - return a * b - elif operation == "divide": - if b == 0: - raise ZeroDivisionError("除数不能为零") - return a / b - else: - raise ValueError(f"不支持的运算类型: {operation},仅支持 add, subtract, multiply, divide") - except Exception as e: - logger.error(f"Calculator error: {e}") - raise - - PRESENT_ARTIFACTS_DESCRIPTION = f""" 将已经生成好的结果文件展示给用户。