feat:添加频率精准控制,移除s4u代码,优化tool返回值

This commit is contained in:
SengokuCola
2025-10-02 01:19:05 +08:00
parent 0692fcac37
commit 92e90a0bee
32 changed files with 173 additions and 4536 deletions

View File

@@ -24,8 +24,9 @@ def init_tool_executor_prompt():
请仔细分析聊天内容,考虑以下几点:
1. 内容中是否包含需要查询信息的问题
2. 是否有明确的工具使用指令
你可以选择多个动作
If you need to use a tool, please directly call the corresponding tool function. If you do not need to use any tool, simply output "No tool needed".
If you need to use tools, please directly call the corresponding tool function. If you do not need to use any tool, simply output "No tool needed".
"""
Prompt(tool_executor_prompt, "tool_executor_prompt")
@@ -177,6 +178,14 @@ class ToolExecutor:
content = tool_info["content"]
if not isinstance(content, (str, list, tuple)):
tool_info["content"] = str(content)
# 空内容直接跳过(空字符串、全空白字符串、空列表/空元组)
content_check = tool_info["content"]
if (
(isinstance(content_check, str) and not content_check.strip())
or (isinstance(content_check, (list, tuple)) and len(content_check) == 0)
):
logger.debug(f"{self.log_prefix}工具{tool_name}无有效内容,跳过展示")
continue
tool_results.append(tool_info)
used_tools.append(tool_name)