PFC消息记录格式与HFC对齐

This commit is contained in:
Bakadax
2025-04-26 20:25:24 +08:00
parent 10282f3d0c
commit d55043a8a5
5 changed files with 59 additions and 42 deletions

View File

@@ -19,6 +19,7 @@ from src.individuality.individuality import Individuality
from .conversation_info import ConversationInfo
from .observation_info import ObservationInfo
import time
from src.plugins.utils.chat_message_builder import build_readable_messages
if TYPE_CHECKING:
pass
@@ -80,19 +81,20 @@ class GoalAnalyzer:
goals_str = f"目标:{goal},产生该对话目标的原因:{reasoning}\n"
# 获取聊天历史记录
chat_history_list = observation_info.chat_history
chat_history_text = ""
for msg in chat_history_list:
chat_history_text += f"{msg}\n"
chat_history_text = observation_info.chat_history
if observation_info.new_messages_count > 0:
new_messages_list = observation_info.unprocessed_messages
new_messages_str = await build_readable_messages(
new_messages_list,
replace_bot_name=True,
merge_messages=False,
timestamp_mode="relative",
read_mark=0.0,
)
chat_history_text += f"\n--- 以下是 {observation_info.new_messages_count} 条新消息 ---\n{new_messages_str}"
chat_history_text += f"{observation_info.new_messages_count}条新消息:\n"
for msg in new_messages_list:
chat_history_text += f"{msg}\n"
observation_info.clear_unprocessed_messages()
# await observation_info.clear_unprocessed_messages()
identity_details_only = self.identity_detail_info
identity_addon = ""
@@ -379,4 +381,4 @@ class DirectMessageSender:
await self.storage.store_message(message, chat_stream)
logger.success(f"PFC消息已发送: {content}")
except Exception as e:
logger.error(f"PFC消息发送失败: {str(e)}")
logger.error(f"PFC消息发送失败: {str(e)}")