better:优化回复逻辑,现在回复前会先思考,移除推理模型再回复中的使用,优化心流运行逻辑,优化思考时间计算逻辑,添加错误检测
This commit is contained in:
@@ -87,13 +87,10 @@ class SubHeartflow:
|
||||
self.is_active = True
|
||||
self.last_active_time = current_time # 更新最后激活时间
|
||||
|
||||
observation = self.observations[0]
|
||||
await observation.observe()
|
||||
|
||||
self.current_state.update_current_state_info()
|
||||
|
||||
await self.do_a_thinking()
|
||||
await self.judge_willing()
|
||||
# await self.do_a_thinking()
|
||||
# await self.judge_willing()
|
||||
await asyncio.sleep(global_config.sub_heart_flow_update_interval)
|
||||
|
||||
# 检查是否超过10分钟没有激活
|
||||
@@ -107,7 +104,7 @@ class SubHeartflow:
|
||||
|
||||
observation = self.observations[0]
|
||||
chat_observe_info = observation.observe_info
|
||||
print(f"chat_observe_info:{chat_observe_info}")
|
||||
# print(f"chat_observe_info:{chat_observe_info}")
|
||||
|
||||
# 调取记忆
|
||||
related_memory = await HippocampusManager.get_instance().get_memory_from_text(
|
||||
@@ -144,8 +141,57 @@ class SubHeartflow:
|
||||
self.current_mind = reponse
|
||||
logger.debug(f"prompt:\n{prompt}\n")
|
||||
logger.info(f"麦麦的脑内状态:{self.current_mind}")
|
||||
|
||||
async def do_observe(self):
|
||||
observation = self.observations[0]
|
||||
await observation.observe()
|
||||
|
||||
async def do_thinking_before_reply(self, message_txt):
|
||||
current_thinking_info = self.current_mind
|
||||
mood_info = self.current_state.mood
|
||||
mood_info = "你很生气,很愤怒"
|
||||
observation = self.observations[0]
|
||||
chat_observe_info = observation.observe_info
|
||||
# print(f"chat_observe_info:{chat_observe_info}")
|
||||
|
||||
async def do_after_reply(self, reply_content, chat_talking_prompt):
|
||||
# 调取记忆
|
||||
related_memory = await HippocampusManager.get_instance().get_memory_from_text(
|
||||
text=chat_observe_info, max_memory_num=2, max_memory_length=2, max_depth=3, fast_retrieval=False
|
||||
)
|
||||
|
||||
if related_memory:
|
||||
related_memory_info = ""
|
||||
for memory in related_memory:
|
||||
related_memory_info += memory[1]
|
||||
else:
|
||||
related_memory_info = ""
|
||||
|
||||
# print(f"相关记忆:{related_memory_info}")
|
||||
|
||||
schedule_info = bot_schedule.get_current_num_task(num=1, time_info=False)
|
||||
|
||||
prompt = ""
|
||||
# prompt += f"麦麦的总体想法是:{self.main_heartflow_info}\n\n"
|
||||
prompt += f"你{self.personality_info}\n"
|
||||
prompt += f"你刚刚在做的事情是:{schedule_info}\n"
|
||||
if related_memory_info:
|
||||
prompt += f"你想起来你之前见过的回忆:{related_memory_info}。\n以上是你的回忆,不一定是目前聊天里的人说的,也不一定是现在发生的事情,请记住。\n"
|
||||
prompt += f"刚刚你的想法是{current_thinking_info}。\n"
|
||||
prompt += "-----------------------------------\n"
|
||||
prompt += f"现在你正在上网,和qq群里的网友们聊天,群里正在聊的话题是:{chat_observe_info}\n"
|
||||
prompt += f"你现在{mood_info}\n"
|
||||
prompt += f"你注意到有人刚刚说:{message_txt}\n"
|
||||
prompt += "现在你接下去继续思考,产生新的想法,不要分点输出,输出连贯的内心独白,不要太长,"
|
||||
prompt += "记得结合上述的消息,要记得维持住你的人设,注意自己的名字,关注有人刚刚说的内容,不要思考太多:"
|
||||
reponse, reasoning_content = await self.llm_model.generate_response_async(prompt)
|
||||
|
||||
self.update_current_mind(reponse)
|
||||
|
||||
self.current_mind = reponse
|
||||
logger.debug(f"prompt:\n{prompt}\n")
|
||||
logger.info(f"麦麦的思考前脑内状态:{self.current_mind}")
|
||||
|
||||
async def do_thinking_after_reply(self, reply_content, chat_talking_prompt):
|
||||
print("麦麦回复之后脑袋转起来了")
|
||||
current_thinking_info = self.current_mind
|
||||
mood_info = self.current_state.mood
|
||||
@@ -155,10 +201,10 @@ class SubHeartflow:
|
||||
|
||||
message_new_info = chat_talking_prompt
|
||||
reply_info = reply_content
|
||||
schedule_info = bot_schedule.get_current_num_task(num=1, time_info=False)
|
||||
# schedule_info = bot_schedule.get_current_num_task(num=1, time_info=False)
|
||||
|
||||
prompt = ""
|
||||
prompt += f"你现在正在做的事情是:{schedule_info}\n"
|
||||
# prompt += f"你现在正在做的事情是:{schedule_info}\n"
|
||||
prompt += f"你{self.personality_info}\n"
|
||||
prompt += f"现在你正在上网,和qq群里的网友们聊天,群里正在聊的话题是:{chat_observe_info}\n"
|
||||
prompt += f"刚刚你的想法是{current_thinking_info}。"
|
||||
|
||||
Reference in New Issue
Block a user