Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into FPC-test
This commit is contained in:
@@ -1,45 +1,45 @@
|
|||||||
# 0.6.3 版本发布前待办事项
|
# 0.6.3 版本发布前待办事项
|
||||||
|
|
||||||
- **统一化人格配置:**
|
- [0.6.3]**统一化人格配置:**
|
||||||
- 检查代码中是否存在硬编码的人格相关配置。
|
- 检查代码中是否存在硬编码的人格相关配置。
|
||||||
- 将所有硬编码的人格配置替换为使用 `individual` 模块进行管理。
|
- 将所有硬编码的人格配置替换为使用 `individual` 模块进行管理。
|
||||||
|
|
||||||
- **在 Planner 中添加回复计数信息:**
|
- [0.6.3]**在 Planner 中添加回复计数信息:**
|
||||||
- 修改 `HeartFlowChatInstance` 的 `Plan` 阶段逻辑。
|
- 修改 `HeartFlowChatInstance` 的 `Plan` 阶段逻辑。
|
||||||
- 将当前周期的回复计数(或其他相关统计信息)作为输入提供给 Planner。
|
- 将当前周期的回复计数(或其他相关统计信息)作为输入提供给 Planner。
|
||||||
- 目的是为 Planner 提供负反馈,减少连续回复或不当回复的可能性。
|
- 目的是为 Planner 提供负反馈,减少连续回复或不当回复的可能性。
|
||||||
|
|
||||||
- **恢复/检查被停止的功能:**
|
- [0.6.3]**恢复/检查被停止的功能:**
|
||||||
- 全面审查代码,特别是对比之前的版本或设计文档。
|
- 全面审查代码,特别是对比之前的版本或设计文档。
|
||||||
- 识别并重新启用那些暂时被禁用但应该恢复的功能。
|
- 识别并重新启用那些暂时被禁用但应该恢复的功能。
|
||||||
- 确认没有核心功能意外丢失。
|
- 确认没有核心功能意外丢失。
|
||||||
|
|
||||||
- **参数提取与配置化:**
|
- [0.6.3]**参数提取与配置化:**
|
||||||
- 识别代码中散落的各种可调参数(例如:概率阈值、时间间隔、次数限制、LLM 模型名称等)。
|
- 识别代码中散落的各种可调参数(例如:概率阈值、时间间隔、次数限制、LLM 模型名称等)。
|
||||||
- 将这些参数统一提取到模块或类的顶部。
|
- 将这些参数统一提取到模块或类的顶部。
|
||||||
- 最终将这些参数移至外部配置文件(如 YAML 或 JSON 文件),方便用户自定义。
|
- 最终将这些参数移至外部配置文件(如 YAML 或 JSON 文件),方便用户自定义。
|
||||||
|
|
||||||
- **提供 HFC (HeartFlowChatInstance) 开启/关闭选项:**
|
- **[0.6.3]提供 HFC (HeartFlowChatInstance) 开启/关闭选项:**
|
||||||
- 增加一个全局或针对特定子心流的配置选项。
|
- 增加一个全局或针对特定子心流的配置选项。
|
||||||
- 允许用户控制是否启用 `FOCUSED` 状态以及关联的 `HeartFlowChatInstance`。
|
- 允许用户控制是否启用 `FOCUSED` 状态以及关联的 `HeartFlowChatInstance`。
|
||||||
- 如果禁用 HFC,子心流可能只会在 `ABSENT` 和 `CHAT` 状态间切换。
|
- 如果禁用 HFC,子心流可能只会在 `ABSENT` 和 `CHAT` 状态间切换。
|
||||||
|
|
||||||
- **添加防破线机制 (针对接收消息):**
|
- [0.6.3]**添加防破线机制 (针对接收消息):**
|
||||||
- 在消息处理流程的早期阶段 (例如 `HeartHC_processor` 或类似模块),增加对接收到的消息文本长度的检查。
|
- 在消息处理流程的早期阶段 (例如 `HeartHC_processor` 或类似模块),增加对接收到的消息文本长度的检查。
|
||||||
- 对超过预设长度阈值的*接收*消息进行截断处理。
|
- 对超过预设长度阈值的*接收*消息进行截断处理。
|
||||||
- 目的是防止过长的输入(可能包含"破限"提示词)影响后续的兴趣计算、LLM 回复生成等环节。
|
- 目的是防止过长的输入(可能包含"破限"提示词)影响后续的兴趣计算、LLM 回复生成等环节。
|
||||||
|
|
||||||
- **NormalChat 模式下的记忆与 Prompt 优化:**
|
- [0.6.3]**NormalChat 模式下的记忆与 Prompt 优化:**
|
||||||
- 重点审视 `NormalChatInstance` (闲聊/推理模式) 中记忆调用 (例如 `HippocampusManager` 的使用) 的方式。
|
- 重点审视 `NormalChatInstance` (闲聊/推理模式) 中记忆调用 (例如 `HippocampusManager` 的使用) 的方式。
|
||||||
- 评估在该模式下引入工具调用 (Tool Calling) 机制以更结构化访问记忆的必要性。
|
- 评估在该模式下引入工具调用 (Tool Calling) 机制以更结构化访问记忆的必要性。
|
||||||
- 优化 `NormalChatInstance` 中与记忆检索、应用相关的 Prompt。
|
- 优化 `NormalChatInstance` 中与记忆检索、应用相关的 Prompt。
|
||||||
|
|
||||||
- **完善简易兴趣监控 GUI:**
|
- [0.6.3]**完善简易兴趣监控 GUI:**
|
||||||
- 改进现有的、用于监控聊天兴趣度 (`InterestChatting`?) 的简单 GUI 界面。
|
- 改进现有的、用于监控聊天兴趣度 (`InterestChatting`?) 的简单 GUI 界面。
|
||||||
- 使其能更清晰地展示关键参数和状态,作为查看日志之外的更直观的监控方式。
|
- 使其能更清晰地展示关键参数和状态,作为查看日志之外的更直观的监控方式。
|
||||||
- 作为完整外部 UI 开发完成前的临时替代方案。
|
- 作为完整外部 UI 开发完成前的临时替代方案。
|
||||||
|
|
||||||
- **修复/完善中期记忆 (Midterm Memory):**
|
- [0.6.3]**修复/完善中期记忆 (Midterm Memory):**
|
||||||
- 检查当前中期记忆模块的状态。
|
- 检查当前中期记忆模块的状态。
|
||||||
- 修复已知问题,使其能够稳定运行。
|
- 修复已知问题,使其能够稳定运行。
|
||||||
- (优先级视开发时间而定)
|
- (优先级视开发时间而定)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ def init_prompt():
|
|||||||
prompt += "{extra_info}\n"
|
prompt += "{extra_info}\n"
|
||||||
prompt += "{prompt_personality}\n"
|
prompt += "{prompt_personality}\n"
|
||||||
prompt += "{last_loop_prompt}\n"
|
prompt += "{last_loop_prompt}\n"
|
||||||
|
prompt += "{cycle_info_block}\n"
|
||||||
prompt += "现在是{time_now},你正在上网,和qq群里的网友们聊天,以下是正在进行的聊天内容:\n{chat_observe_info}\n"
|
prompt += "现在是{time_now},你正在上网,和qq群里的网友们聊天,以下是正在进行的聊天内容:\n{chat_observe_info}\n"
|
||||||
prompt += "\n你现在{mood_info}\n"
|
prompt += "\n你现在{mood_info}\n"
|
||||||
prompt += (
|
prompt += (
|
||||||
@@ -66,7 +67,7 @@ class SubMind:
|
|||||||
self.past_mind = []
|
self.past_mind = []
|
||||||
self.structured_info = {}
|
self.structured_info = {}
|
||||||
|
|
||||||
async def do_thinking_before_reply(self, last_cycle: CycleInfo = None):
|
async def do_thinking_before_reply(self, history_cycle: list[CycleInfo] = None):
|
||||||
"""
|
"""
|
||||||
在回复前进行思考,生成内心想法并收集工具调用结果
|
在回复前进行思考,生成内心想法并收集工具调用结果
|
||||||
|
|
||||||
@@ -130,6 +131,7 @@ class SubMind:
|
|||||||
("进行深入思考", 0.2),
|
("进行深入思考", 0.2),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
last_cycle = history_cycle[-1] if history_cycle else None
|
||||||
# 上一次决策信息
|
# 上一次决策信息
|
||||||
if last_cycle != None:
|
if last_cycle != None:
|
||||||
last_action = last_cycle.action_type
|
last_action = last_cycle.action_type
|
||||||
@@ -151,6 +153,49 @@ class SubMind:
|
|||||||
else:
|
else:
|
||||||
last_loop_prompt = ""
|
last_loop_prompt = ""
|
||||||
|
|
||||||
|
# 准备循环信息块 (分析最近的活动循环)
|
||||||
|
recent_active_cycles = []
|
||||||
|
for cycle in reversed(history_cycle):
|
||||||
|
# 只关心实际执行了动作的循环
|
||||||
|
if cycle.action_taken:
|
||||||
|
recent_active_cycles.append(cycle)
|
||||||
|
# 最多找最近的3个活动循环
|
||||||
|
if len(recent_active_cycles) == 3:
|
||||||
|
break
|
||||||
|
|
||||||
|
cycle_info_block = ""
|
||||||
|
consecutive_text_replies = 0
|
||||||
|
responses_for_prompt = []
|
||||||
|
|
||||||
|
# 检查这最近的活动循环中有多少是连续的文本回复 (从最近的开始看)
|
||||||
|
for cycle in recent_active_cycles:
|
||||||
|
if cycle.action_type == "text_reply":
|
||||||
|
consecutive_text_replies += 1
|
||||||
|
# 获取回复内容,如果不存在则返回'[空回复]'
|
||||||
|
response_text = cycle.response_info.get("response_text", [])
|
||||||
|
# 使用简单的 join 来格式化回复内容列表
|
||||||
|
formatted_response = "[空回复]" if not response_text else " ".join(response_text)
|
||||||
|
responses_for_prompt.append(formatted_response)
|
||||||
|
else:
|
||||||
|
# 一旦遇到非文本回复,连续性中断
|
||||||
|
break
|
||||||
|
|
||||||
|
# 根据连续文本回复的数量构建提示信息
|
||||||
|
# 注意: responses_for_prompt 列表是从最近到最远排序的
|
||||||
|
if consecutive_text_replies >= 3: # 如果最近的三个活动都是文本回复
|
||||||
|
cycle_info_block = f'你已经连续回复了三条消息(最近: "{responses_for_prompt[0]}",第二近: "{responses_for_prompt[1]}",第三近: "{responses_for_prompt[2]}")。你回复的有点多了,请注意'
|
||||||
|
elif consecutive_text_replies == 2: # 如果最近的两个活动是文本回复
|
||||||
|
cycle_info_block = f'你已经连续回复了两条消息(最近: "{responses_for_prompt[0]}",第二近: "{responses_for_prompt[1]}"),请注意'
|
||||||
|
elif consecutive_text_replies == 1: # 如果最近的一个活动是文本回复
|
||||||
|
cycle_info_block = f'你刚刚已经回复一条消息(内容: "{responses_for_prompt[0]}")'
|
||||||
|
|
||||||
|
# 包装提示块,增加可读性,即使没有连续回复也给个标记
|
||||||
|
if cycle_info_block:
|
||||||
|
cycle_info_block = f"\n【近期回复历史】\n{cycle_info_block}\n"
|
||||||
|
else:
|
||||||
|
# 如果最近的活动循环不是文本回复,或者没有活动循环
|
||||||
|
cycle_info_block = "\n【近期回复历史】\n(最近没有连续文本回复)\n"
|
||||||
|
|
||||||
# 加权随机选择思考指导
|
# 加权随机选择思考指导
|
||||||
hf_do_next = local_random.choices(
|
hf_do_next = local_random.choices(
|
||||||
[option[0] for option in hf_options], weights=[option[1] for option in hf_options], k=1
|
[option[0] for option in hf_options], weights=[option[1] for option in hf_options], k=1
|
||||||
@@ -167,6 +212,7 @@ class SubMind:
|
|||||||
mood_info=mood_info,
|
mood_info=mood_info,
|
||||||
hf_do_next=hf_do_next,
|
hf_do_next=hf_do_next,
|
||||||
last_loop_prompt=last_loop_prompt,
|
last_loop_prompt=last_loop_prompt,
|
||||||
|
cycle_info_block=cycle_info_block,
|
||||||
)
|
)
|
||||||
|
|
||||||
# logger.debug(f"[{self.subheartflow_id}] 心流思考提示词构建完成")
|
# logger.debug(f"[{self.subheartflow_id}] 心流思考提示词构建完成")
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ class HeartFChatting:
|
|||||||
|
|
||||||
# 在获取规划结果后检查新消息
|
# 在获取规划结果后检查新消息
|
||||||
if await self._check_new_messages(planner_start_db_time):
|
if await self._check_new_messages(planner_start_db_time):
|
||||||
if random.random() < 0.3:
|
if random.random() < 0.2:
|
||||||
logger.info(f"{self.log_prefix} 看到了新消息,麦麦决定重新观察和规划...")
|
logger.info(f"{self.log_prefix} 看到了新消息,麦麦决定重新观察和规划...")
|
||||||
# 重新规划
|
# 重新规划
|
||||||
with Timer("重新决策", cycle_timers):
|
with Timer("重新决策", cycle_timers):
|
||||||
@@ -705,12 +705,14 @@ class HeartFChatting:
|
|||||||
await observation.observe()
|
await observation.observe()
|
||||||
|
|
||||||
# 获取上一个循环的信息
|
# 获取上一个循环的信息
|
||||||
last_cycle = self._cycle_history[-1] if self._cycle_history else None
|
# last_cycle = self._cycle_history[-1] if self._cycle_history else None
|
||||||
|
|
||||||
with Timer("思考", cycle_timers):
|
with Timer("思考", cycle_timers):
|
||||||
# 获取上一个循环的动作
|
# 获取上一个循环的动作
|
||||||
# 传递上一个循环的信息给 do_thinking_before_reply
|
# 传递上一个循环的信息给 do_thinking_before_reply
|
||||||
current_mind, _past_mind = await self.sub_mind.do_thinking_before_reply(last_cycle=last_cycle)
|
current_mind, _past_mind = await self.sub_mind.do_thinking_before_reply(
|
||||||
|
history_cycle=self._cycle_history
|
||||||
|
)
|
||||||
return current_mind
|
return current_mind
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{self.log_prefix}[SubMind] 思考失败: {e}")
|
logger.error(f"{self.log_prefix}[SubMind] 思考失败: {e}")
|
||||||
@@ -762,9 +764,15 @@ class HeartFChatting:
|
|||||||
# 执行LLM请求
|
# 执行LLM请求
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
print("prompt")
|
||||||
|
print("prompt")
|
||||||
|
print("prompt")
|
||||||
|
print(payload)
|
||||||
|
print(prompt)
|
||||||
response = await self.planner_llm._execute_request(
|
response = await self.planner_llm._execute_request(
|
||||||
endpoint="/chat/completions", payload=payload, prompt=prompt
|
endpoint="/chat/completions", payload=payload, prompt=prompt
|
||||||
)
|
)
|
||||||
|
print(response)
|
||||||
except Exception as req_e:
|
except Exception as req_e:
|
||||||
logger.error(f"{self.log_prefix}[Planner] LLM请求执行失败: {req_e}")
|
logger.error(f"{self.log_prefix}[Planner] LLM请求执行失败: {req_e}")
|
||||||
return {
|
return {
|
||||||
@@ -779,6 +787,9 @@ class HeartFChatting:
|
|||||||
# 处理LLM响应
|
# 处理LLM响应
|
||||||
with Timer("使用工具", cycle_timers):
|
with Timer("使用工具", cycle_timers):
|
||||||
# 使用辅助函数处理工具调用响应
|
# 使用辅助函数处理工具调用响应
|
||||||
|
print(1111122222222222)
|
||||||
|
print(response)
|
||||||
|
|
||||||
success, arguments, error_msg = process_llm_tool_response(
|
success, arguments, error_msg = process_llm_tool_response(
|
||||||
response, expected_tool_name="decide_reply_action", log_prefix=f"{self.log_prefix}[Planner] "
|
response, expected_tool_name="decide_reply_action", log_prefix=f"{self.log_prefix}[Planner] "
|
||||||
)
|
)
|
||||||
@@ -968,38 +979,87 @@ class HeartFChatting:
|
|||||||
replan_prompt: str,
|
replan_prompt: str,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""构建 Planner LLM 的提示词"""
|
"""构建 Planner LLM 的提示词"""
|
||||||
|
try:
|
||||||
|
# 准备结构化信息块
|
||||||
|
structured_info_block = ""
|
||||||
|
if structured_info:
|
||||||
|
structured_info_block = f"以下是一些额外的信息:\n{structured_info}\n"
|
||||||
|
|
||||||
# 准备结构化信息块
|
# 准备聊天内容块
|
||||||
structured_info_block = ""
|
chat_content_block = ""
|
||||||
if structured_info:
|
if observed_messages_str:
|
||||||
structured_info_block = f"以下是一些额外的信息:\n{structured_info}\n"
|
chat_content_block = "观察到的最新聊天内容如下:\n---\n"
|
||||||
|
chat_content_block += observed_messages_str
|
||||||
|
chat_content_block += "\n---"
|
||||||
|
else:
|
||||||
|
chat_content_block = "当前没有观察到新的聊天内容。\n"
|
||||||
|
|
||||||
# 准备聊天内容块
|
# 准备当前思维块
|
||||||
chat_content_block = ""
|
current_mind_block = ""
|
||||||
if observed_messages_str:
|
if current_mind:
|
||||||
chat_content_block = "观察到的最新聊天内容如下:\n---\n"
|
current_mind_block = f"{current_mind}"
|
||||||
chat_content_block += observed_messages_str
|
else:
|
||||||
chat_content_block += "\n---"
|
current_mind_block = "[没有特别的想法]"
|
||||||
else:
|
|
||||||
chat_content_block = "当前没有观察到新的聊天内容。\n"
|
|
||||||
|
|
||||||
# 准备当前思维块
|
# 准备循环信息块 (分析最近的活动循环)
|
||||||
current_mind_block = ""
|
recent_active_cycles = []
|
||||||
if current_mind:
|
for cycle in reversed(self._cycle_history):
|
||||||
current_mind_block = f"{current_mind}"
|
# 只关心实际执行了动作的循环
|
||||||
else:
|
if cycle.action_taken:
|
||||||
current_mind_block = "[没有特别的想法]"
|
recent_active_cycles.append(cycle)
|
||||||
|
# 最多找最近的3个活动循环
|
||||||
|
if len(recent_active_cycles) == 3:
|
||||||
|
break
|
||||||
|
|
||||||
# 获取提示词模板并填充数据
|
cycle_info_block = ""
|
||||||
prompt = (await global_prompt_manager.get_prompt_async("planner_prompt")).format(
|
consecutive_text_replies = 0
|
||||||
bot_name=global_config.BOT_NICKNAME,
|
responses_for_prompt = []
|
||||||
structured_info_block=structured_info_block,
|
|
||||||
chat_content_block=chat_content_block,
|
|
||||||
current_mind_block=current_mind_block,
|
|
||||||
replan=replan_prompt,
|
|
||||||
)
|
|
||||||
|
|
||||||
return prompt
|
# 检查这最近的活动循环中有多少是连续的文本回复 (从最近的开始看)
|
||||||
|
for cycle in recent_active_cycles:
|
||||||
|
if cycle.action_type == "text_reply":
|
||||||
|
consecutive_text_replies += 1
|
||||||
|
# 获取回复内容,如果不存在则返回'[空回复]'
|
||||||
|
response_text = cycle.response_info.get("response_text", [])
|
||||||
|
# 使用简单的 join 来格式化回复内容列表
|
||||||
|
formatted_response = "[空回复]" if not response_text else " ".join(response_text)
|
||||||
|
responses_for_prompt.append(formatted_response)
|
||||||
|
else:
|
||||||
|
# 一旦遇到非文本回复,连续性中断
|
||||||
|
break
|
||||||
|
|
||||||
|
# 根据连续文本回复的数量构建提示信息
|
||||||
|
# 注意: responses_for_prompt 列表是从最近到最远排序的
|
||||||
|
if consecutive_text_replies >= 3: # 如果最近的三个活动都是文本回复
|
||||||
|
cycle_info_block = f'你已经连续回复了三条消息(最近: "{responses_for_prompt[0]}",第二近: "{responses_for_prompt[1]}",第三近: "{responses_for_prompt[2]}")。你回复的有点多了,请注意'
|
||||||
|
elif consecutive_text_replies == 2: # 如果最近的两个活动是文本回复
|
||||||
|
cycle_info_block = f'你已经连续回复了两条消息(最近: "{responses_for_prompt[0]}",第二近: "{responses_for_prompt[1]}"),请注意'
|
||||||
|
elif consecutive_text_replies == 1: # 如果最近的一个活动是文本回复
|
||||||
|
cycle_info_block = f'你刚刚已经回复一条消息(内容: "{responses_for_prompt[0]}")'
|
||||||
|
|
||||||
|
# 包装提示块,增加可读性,即使没有连续回复也给个标记
|
||||||
|
if cycle_info_block:
|
||||||
|
cycle_info_block = f"\n【近期回复历史】\n{cycle_info_block}\n"
|
||||||
|
else:
|
||||||
|
# 如果最近的活动循环不是文本回复,或者没有活动循环
|
||||||
|
cycle_info_block = "\n【近期回复历史】\n(最近没有连续文本回复)\n"
|
||||||
|
|
||||||
|
# 获取提示词模板并填充数据
|
||||||
|
prompt = (await global_prompt_manager.get_prompt_async("planner_prompt")).format(
|
||||||
|
bot_name=global_config.BOT_NICKNAME,
|
||||||
|
structured_info_block=structured_info_block,
|
||||||
|
chat_content_block=chat_content_block,
|
||||||
|
current_mind_block=current_mind_block,
|
||||||
|
replan=replan_prompt,
|
||||||
|
cycle_info_block=cycle_info_block,
|
||||||
|
)
|
||||||
|
|
||||||
|
return prompt
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"{self.log_prefix}[Planner] 构建提示词时出错: {e}")
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
return ""
|
||||||
|
|
||||||
# --- 回复器 (Replier) 的定义 --- #
|
# --- 回复器 (Replier) 的定义 --- #
|
||||||
async def _replier_work(
|
async def _replier_work(
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ def init_prompt():
|
|||||||
你的内心想法:
|
你的内心想法:
|
||||||
{current_mind_block}
|
{current_mind_block}
|
||||||
{replan}
|
{replan}
|
||||||
|
{cycle_info_block}
|
||||||
|
|
||||||
请综合分析聊天内容和你看到的新消息,参考内心想法,使用'decide_reply_action'工具做出决策。决策时请注意:
|
请综合分析聊天内容和你看到的新消息,参考内心想法,使用'decide_reply_action'工具做出决策。决策时请注意:
|
||||||
|
|
||||||
|
|||||||
@@ -213,6 +213,9 @@ def process_llm_tool_calls(response: List[Any], log_prefix: str = "") -> Tuple[b
|
|||||||
元组 (成功标志, 工具调用列表, 错误消息)
|
元组 (成功标志, 工具调用列表, 错误消息)
|
||||||
"""
|
"""
|
||||||
# 确保响应格式正确
|
# 确保响应格式正确
|
||||||
|
print(response)
|
||||||
|
print(11111111111111111)
|
||||||
|
|
||||||
if len(response) != 3:
|
if len(response) != 3:
|
||||||
return False, [], f"LLM响应元素数量不正确: 预期3个元素,实际{len(response)}个"
|
return False, [], f"LLM响应元素数量不正确: 预期3个元素,实际{len(response)}个"
|
||||||
|
|
||||||
@@ -274,7 +277,17 @@ def process_llm_tool_response(
|
|||||||
if not success:
|
if not success:
|
||||||
return False, {}, error_msg
|
return False, {}, error_msg
|
||||||
|
|
||||||
|
# 新增检查:确保响应包含预期的工具调用部分
|
||||||
|
if len(normalized_response) != 3:
|
||||||
|
# 如果长度不为3,说明LLM响应不包含工具调用部分,这在期望工具调用的上下文中是错误的
|
||||||
|
error_msg = (
|
||||||
|
f"LLM响应未包含预期的工具调用部分: 元素数量{len(normalized_response)},响应内容:{normalized_response}"
|
||||||
|
)
|
||||||
|
logger.warning(f"{log_prefix}{error_msg}")
|
||||||
|
return False, {}, error_msg
|
||||||
|
|
||||||
# 使用新的工具调用处理函数
|
# 使用新的工具调用处理函数
|
||||||
|
# 此时已知 normalized_response 长度必定为 3
|
||||||
success, valid_tool_calls, error_msg = process_llm_tool_calls(normalized_response, log_prefix)
|
success, valid_tool_calls, error_msg = process_llm_tool_calls(normalized_response, log_prefix)
|
||||||
if not success:
|
if not success:
|
||||||
return False, {}, error_msg
|
return False, {}, error_msg
|
||||||
|
|||||||
Reference in New Issue
Block a user