feat: 启用message中的format_info功能
This commit is contained in:
@@ -5,6 +5,8 @@ from src.chat.focus_chat.info.action_info import ActionInfo
|
||||
from .base_processor import BaseProcessor
|
||||
from src.common.logger_manager import get_logger
|
||||
from src.chat.heart_flow.observation.hfcloop_observation import HFCloopObservation
|
||||
from src.chat.heart_flow.observation.chatting_observation import ChattingObservation
|
||||
from src.chat.message_receive.chat_stream import ChatStream, chat_manager
|
||||
from typing import Dict
|
||||
from src.chat.models.utils_model import LLMRequest
|
||||
from src.config.config import global_config
|
||||
@@ -50,10 +52,12 @@ class ActionProcessor(BaseProcessor):
|
||||
|
||||
# 处理Observation对象
|
||||
if observations:
|
||||
action_info = ActionInfo()
|
||||
all_actions = None
|
||||
for obs in observations:
|
||||
if isinstance(obs, HFCloopObservation):
|
||||
# 创建动作信息
|
||||
action_info = ActionInfo()
|
||||
all_actions = obs.all_actions
|
||||
action_changes = await self.analyze_loop_actions(obs)
|
||||
if action_changes["add"] or action_changes["remove"]:
|
||||
action_info.set_action_changes(action_changes)
|
||||
@@ -64,7 +68,27 @@ class ActionProcessor(BaseProcessor):
|
||||
if action_changes["remove"]:
|
||||
reasons.append(f"移除动作{action_changes['remove']}因为检测到连续回复")
|
||||
action_info.set_reason(" | ".join(reasons))
|
||||
processed_infos.append(action_info)
|
||||
if isinstance(obs, ChattingObservation) and all_actions is not None:
|
||||
action_changes = {"add": [], "remove": []}
|
||||
# 检查动作的关联类型
|
||||
chat_context = chat_manager.get_stream(obs.chat_id).context
|
||||
for action_name in all_actions.keys():
|
||||
data = all_actions[action_name]
|
||||
if data.get("associated_types"):
|
||||
if not chat_context.check_types(data["associated_types"]):
|
||||
action_changes["remove"].append(action_name)
|
||||
logger.debug(f"{self.log_prefix} 动作 {action_name} 关联类型不匹配,移除该动作")
|
||||
if len(action_changes["remove"]) > 0:
|
||||
action_info.set_action_changes(action_changes)
|
||||
# 设置变更原因
|
||||
reasons = []
|
||||
if action_info.get_reason():
|
||||
reasons.append(action_info.get_reason())
|
||||
if action_changes["remove"]:
|
||||
reasons.append(f"移除动作{action_changes['remove']}因为关联类型不匹配")
|
||||
action_info.set_reason(" | ".join(reasons))
|
||||
|
||||
processed_infos.append(action_info)
|
||||
|
||||
return processed_infos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user