fix:修复了心流观察不到群消息的bug

This commit is contained in:
SengokuCola
2025-03-31 00:10:37 +08:00
parent d44817e2a8
commit 1e4cdc8ce3
3 changed files with 11 additions and 6 deletions

View File

@@ -51,8 +51,10 @@ class ChattingObservation(Observation):
# 将新消息转换为字符串格式 # 将新消息转换为字符串格式
new_messages_str = "" new_messages_str = ""
for msg in new_messages: for msg in new_messages:
if "sender_name" in msg and "content" in msg: if "detailed_plain_text" in msg:
new_messages_str += f"{msg['sender_name']}: {msg['content']}\n" new_messages_str += f"{msg['detailed_plain_text']}\n"
print(f"new_messages_str{new_messages_str}")
# 将新消息添加到talking_message同时保持列表长度不超过20条 # 将新消息添加到talking_message同时保持列表长度不超过20条
self.talking_message.extend(new_messages) self.talking_message.extend(new_messages)
@@ -90,8 +92,8 @@ class ChattingObservation(Observation):
# 将新消息转换为字符串格式 # 将新消息转换为字符串格式
new_messages_str = "" new_messages_str = ""
for msg in new_messages: for msg in new_messages:
if "sender_name" in msg and "content" in msg: if "detailed_plain_text" in msg:
new_messages_str += f"{msg['sender_name']}: {msg['content']}\n" new_messages_str += f"{msg['detailed_plain_text']}\n"
# 将新消息添加到talking_message同时保持列表长度不超过30条 # 将新消息添加到talking_message同时保持列表长度不超过30条
self.talking_message.extend(new_messages) self.talking_message.extend(new_messages)
@@ -116,6 +118,9 @@ class ChattingObservation(Observation):
以及聊天中的一些重要信息,记得不要分点,不要太长,精简的概括成一段文本\n""" 以及聊天中的一些重要信息,记得不要分点,不要太长,精简的概括成一段文本\n"""
prompt += "总结概括:" prompt += "总结概括:"
self.observe_info, reasoning_content = await self.llm_summary.generate_response_async(prompt) self.observe_info, reasoning_content = await self.llm_summary.generate_response_async(prompt)
print(f"prompt{prompt}")
print(f"self.observe_info{self.observe_info}")
def translate_message_list_to_str(self): def translate_message_list_to_str(self):
self.talking_message_str = "" self.talking_message_str = ""

View File

@@ -146,7 +146,7 @@ class SubHeartflow:
logger.info(f"麦麦的脑内状态:{self.current_mind}") logger.info(f"麦麦的脑内状态:{self.current_mind}")
async def do_after_reply(self, reply_content, chat_talking_prompt): async def do_after_reply(self, reply_content, chat_talking_prompt):
# print("麦麦脑袋转起来了") print("麦麦回复之后脑袋转起来了")
current_thinking_info = self.current_mind current_thinking_info = self.current_mind
mood_info = self.current_state.mood mood_info = self.current_state.mood

View File

@@ -66,7 +66,7 @@ heart_flow_update_interval = 300 # 心流更新频率,间隔 单位秒
max_context_size = 15 # 麦麦获得的上文数量建议15太短太长都会导致脑袋尖尖 max_context_size = 15 # 麦麦获得的上文数量建议15太短太长都会导致脑袋尖尖
emoji_chance = 0.2 # 麦麦使用表情包的概率 emoji_chance = 0.2 # 麦麦使用表情包的概率
thinking_timeout = 120 # 麦麦最长思考时间,超过这个时间的思考会放弃 thinking_timeout = 120 # 麦麦最长思考时间,超过这个时间的思考会放弃
max_response_length = 1024 # 麦麦回答的最大token数 max_response_length = 256 # 麦麦回答的最大token数
ban_words = [ ban_words = [
# "403","张三" # "403","张三"
] ]