feat:将action选择从处理器转变为单独阶段,增加action使用的准确性

This commit is contained in:
SengokuCola
2025-05-29 10:16:34 +08:00
parent 3cf7776966
commit b551710c13
8 changed files with 114 additions and 73 deletions

View File

@@ -101,29 +101,26 @@ class ActionPlanner:
# 获取观察信息
extra_info: list[str] = []
# 首先处理动作变更
for info in all_plan_info:
if isinstance(info, ActionInfo) and info.has_changes():
add_actions = info.get_add_actions()
remove_actions = info.get_remove_actions()
reason = info.get_reason()
print(f"{self.log_prefix} 动作变更: {add_actions} {remove_actions} {reason}")
# # 首先处理动作变更
# for info in all_plan_info:
# if isinstance(info, ActionInfo) and info.has_changes():
# add_actions = info.get_add_actions()
# remove_actions = info.get_remove_actions()
# reason = info.get_reason()
# print(f"{self.log_prefix} 动作变更: {add_actions} {remove_actions} {reason}")
# 处理动作的增加
for action_name in add_actions:
if action_name in self.action_manager.get_registered_actions():
self.action_manager.add_action_to_using(action_name)
logger.debug(f"{self.log_prefix}添加动作: {action_name}, 原因: {reason}")
# # 处理动作的增加
# for action_name in add_actions:
# if action_name in self.action_manager.get_registered_actions():
# self.action_manager.add_action_to_using(action_name)
# logger.debug(f"{self.log_prefix}添加动作: {action_name}, 原因: {reason}")
# # 处理动作的移除
# for action_name in remove_actions:
# self.action_manager.remove_action_from_using(action_name)
# logger.debug(f"{self.log_prefix}移除动作: {action_name}, 原因: {reason}")
# 处理动作的移除
for action_name in remove_actions:
self.action_manager.remove_action_from_using(action_name)
logger.debug(f"{self.log_prefix}移除动作: {action_name}, 原因: {reason}")
# 如果当前选择的动作被移除了更新为no_reply
if action in remove_actions:
action = "no_reply"
reasoning = f"之前选择的动作{action}已被移除,原因: {reason}"
# 继续处理其他信息
self_info = ""
@@ -146,8 +143,8 @@ class ActionPlanner:
elif isinstance(info, StructuredInfo):
structured_info = info.get_processed_info()
# print(f"structured_info: {structured_info}")
elif not isinstance(info, ActionInfo): # 跳过已处理的ActionInfo
extra_info.append(info.get_processed_info())
# elif not isinstance(info, ActionInfo): # 跳过已处理的ActionInfo
# extra_info.append(info.get_processed_info())
# 获取当前可用的动作
current_available_actions = self.action_manager.get_using_actions()