mirror of https://github.com/Mai-with-u/MaiBot.git
Merge branch 'dev' of https://github.com/SnowindMe/MaiBot into dev
commit
882238f460
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
|
|
@ -41,7 +41,7 @@ class CompareNumbersTool(BaseTool):
|
|||
CompareNumbers = run_lua_code(lua_code).CompareNumbers
|
||||
result = CompareNumbers(num1, num2)
|
||||
|
||||
return {"name": self.name, "content": result}
|
||||
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)}"}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
from src.tools.tool_can_use.base_tool import BaseTool, run_lua_code
|
||||
from src.common.logger_manager import get_logger
|
||||
from typing import Dict, Any
|
||||
|
||||
logger = get_logger("get_time_date")
|
||||
|
||||
|
||||
class GetCurrentDateTimeTool(BaseTool):
|
||||
"""获取当前时间、日期、年份和星期的工具"""
|
||||
|
||||
name = "get_current_date_time"
|
||||
description = "当有人询问或者涉及到具体时间或者日期的时候,必须使用这个工具"
|
||||
parameters = {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": [],
|
||||
}
|
||||
|
||||
async def execute(self, function_args: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""执行获取当前时间、日期、年份和星期
|
||||
|
||||
Args:
|
||||
function_args: 工具参数(此工具不使用)
|
||||
|
||||
Returns:
|
||||
Dict: 工具执行结果
|
||||
"""
|
||||
lua_code = """
|
||||
GetCurrentDateTime = function()
|
||||
return ("当前时间: %s, 日期: %s, 年份: %s, 星期: %s"):format(os.date("%H:%M:%S"), os.date("%Y-%m-%d"), os.date("%Y"), os.date("%A"))
|
||||
end
|
||||
"""
|
||||
GetCurrentDateTime = run_lua_code(lua_code).GetCurrentDateTime
|
||||
return {
|
||||
"name": "get_current_date_time",
|
||||
"content": GetCurrentDateTime(),
|
||||
}
|
||||
Loading…
Reference in New Issue