mirror of https://github.com/Mai-with-u/MaiBot.git
Update compare_numbers_tool.py
parent
5780765cb7
commit
de393be088
|
|
@ -9,12 +9,12 @@ class CompareNumbersTool(BaseTool):
|
|||
"""比较两个数大小的工具"""
|
||||
|
||||
name = "compare_numbers"
|
||||
description = "使用工具 比较两个数的大小,返回较大的数"
|
||||
description = "Compare two numbers and determine their relationship (greater than, less than, or equal). Returns comparison result and the larger number if they are not equal."
|
||||
parameters = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"num1": {"type": "number", "description": "第一个数字"},
|
||||
"num2": {"type": "number", "description": "第二个数字"},
|
||||
"num1": {"type": "number", "description": "The first number to compare."},
|
||||
"num2": {"type": "number", "description": "The second number to compare."},
|
||||
},
|
||||
"required": ["num1", "num2"],
|
||||
}
|
||||
|
|
@ -33,16 +33,16 @@ class CompareNumbersTool(BaseTool):
|
|||
num2 = function_args.get("num2")
|
||||
|
||||
if num1 > num2:
|
||||
result = f"{num1} 大于 {num2}"
|
||||
result = f"{num1} is greater than {num2}"
|
||||
elif num1 < num2:
|
||||
result = f"{num1} 小于 {num2}"
|
||||
result = f"{num1} is less than {num2}"
|
||||
else:
|
||||
result = f"{num1} 等于 {num2}"
|
||||
result = f"{num1} is equal to {num2}"
|
||||
|
||||
return {"type": "comparison_result", "id": f"{num1}_vs_{num2}", "content": result}
|
||||
except Exception as e:
|
||||
logger.error(f"比较数字失败: {str(e)}")
|
||||
return {"type": "info", "id": f"{num1}_vs_{num2}", "content": f"比较数字失败,炸了: {str(e)}"}
|
||||
logger.error(f"Failed to compare numbers: {str(e)}")
|
||||
return {"type": "info", "id": f"{num1}_vs_{num2}", "content": f"Failed to compare numbers: {str(e)}"}
|
||||
|
||||
|
||||
# 注册工具
|
||||
|
|
|
|||
Loading…
Reference in New Issue