fix:微操
This commit is contained in:
@@ -78,7 +78,7 @@ class ChatBot:
|
|||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
await message.process()
|
await message.process()
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
logger.info(f"2消息处理时间: {timer2 - timer1}秒")
|
logger.debug(f"2消息处理时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
# 过滤词/正则表达式过滤
|
# 过滤词/正则表达式过滤
|
||||||
if (
|
if (
|
||||||
@@ -97,7 +97,7 @@ class ChatBot:
|
|||||||
message.processed_plain_text, fast_retrieval=True
|
message.processed_plain_text, fast_retrieval=True
|
||||||
)
|
)
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
logger.info(f"3记忆激活时间: {timer2 - timer1}秒")
|
logger.debug(f"3记忆激活时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
|
|
||||||
is_mentioned = is_mentioned_bot_in_message(message)
|
is_mentioned = is_mentioned_bot_in_message(message)
|
||||||
@@ -122,7 +122,7 @@ class ChatBot:
|
|||||||
sender_id=str(message.message_info.user_info.user_id),
|
sender_id=str(message.message_info.user_info.user_id),
|
||||||
)
|
)
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
logger.info(f"4计算意愿激活时间: {timer2 - timer1}秒")
|
logger.debug(f"4计算意愿激活时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
#神秘的消息流数据结构处理
|
#神秘的消息流数据结构处理
|
||||||
if chat.group_info:
|
if chat.group_info:
|
||||||
@@ -168,7 +168,7 @@ class ChatBot:
|
|||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
await self._handle_emoji(message, chat, response_set)
|
await self._handle_emoji(message, chat, response_set)
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
logger.info(f"8处理表情包时间: {timer2 - timer1}秒")
|
logger.debug(f"8处理表情包时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
await self._update_using_response(message, chat, response_set)
|
await self._update_using_response(message, chat, response_set)
|
||||||
@@ -229,7 +229,7 @@ class ChatBot:
|
|||||||
container = message_manager.get_container(chat.stream_id)
|
container = message_manager.get_container(chat.stream_id)
|
||||||
thinking_message = None
|
thinking_message = None
|
||||||
|
|
||||||
logger.info(f"开始发送消息准备")
|
# logger.info(f"开始发送消息准备")
|
||||||
for msg in container.messages:
|
for msg in container.messages:
|
||||||
if isinstance(msg, MessageThinking) and msg.message_info.message_id == thinking_id:
|
if isinstance(msg, MessageThinking) and msg.message_info.message_id == thinking_id:
|
||||||
thinking_message = msg
|
thinking_message = msg
|
||||||
@@ -240,7 +240,7 @@ class ChatBot:
|
|||||||
logger.warning("未找到对应的思考消息,可能已超时被移除")
|
logger.warning("未找到对应的思考消息,可能已超时被移除")
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"开始发送消息")
|
# logger.info(f"开始发送消息")
|
||||||
thinking_start_time = thinking_message.thinking_start_time
|
thinking_start_time = thinking_message.thinking_start_time
|
||||||
message_set = MessageSet(chat, thinking_id)
|
message_set = MessageSet(chat, thinking_id)
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ class ChatBot:
|
|||||||
if not mark_head:
|
if not mark_head:
|
||||||
mark_head = True
|
mark_head = True
|
||||||
message_set.add_message(bot_message)
|
message_set.add_message(bot_message)
|
||||||
logger.info(f"开始添加发送消息")
|
# logger.info(f"开始添加发送消息")
|
||||||
message_manager.add_message(message_set)
|
message_manager.add_message(message_set)
|
||||||
|
|
||||||
async def _handle_emoji(self, message, chat, response):
|
async def _handle_emoji(self, message, chat, response):
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ class ResponseGenerator:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
async def _generate_response_with_model(self, message: MessageThinking, model: LLM_request):
|
async def _generate_response_with_model(self, message: MessageThinking, model: LLM_request):
|
||||||
"""使用指定的模型生成回复"""
|
|
||||||
logger.info(f"开始使用生成回复-1")
|
|
||||||
sender_name = ""
|
sender_name = ""
|
||||||
if message.chat_stream.user_info.user_cardname and message.chat_stream.user_info.user_nickname:
|
if message.chat_stream.user_info.user_cardname and message.chat_stream.user_info.user_nickname:
|
||||||
sender_name = (
|
sender_name = (
|
||||||
@@ -84,7 +82,7 @@ class ResponseGenerator:
|
|||||||
else:
|
else:
|
||||||
sender_name = f"用户({message.chat_stream.user_info.user_id})"
|
sender_name = f"用户({message.chat_stream.user_info.user_id})"
|
||||||
|
|
||||||
logger.info(f"开始使用生成回复-2")
|
logger.debug(f"开始使用生成回复-2")
|
||||||
# 构建prompt
|
# 构建prompt
|
||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
prompt = await prompt_builder._build_prompt(
|
prompt = await prompt_builder._build_prompt(
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Heartflow:
|
|||||||
del self._subheartflows[subheartflow_id]
|
del self._subheartflows[subheartflow_id]
|
||||||
logger.info(f"已清理不活跃的子心流: {subheartflow_id}")
|
logger.info(f"已清理不活跃的子心流: {subheartflow_id}")
|
||||||
|
|
||||||
await asyncio.sleep(60) # 每分钟检查一次
|
await asyncio.sleep(30) # 每分钟检查一次
|
||||||
|
|
||||||
async def heartflow_start_working(self):
|
async def heartflow_start_working(self):
|
||||||
# 启动清理任务
|
# 启动清理任务
|
||||||
@@ -65,7 +65,7 @@ class Heartflow:
|
|||||||
while True:
|
while True:
|
||||||
# 检查是否存在子心流
|
# 检查是否存在子心流
|
||||||
if not self._subheartflows:
|
if not self._subheartflows:
|
||||||
logger.debug("当前没有子心流,等待新的子心流创建...")
|
logger.info("当前没有子心流,等待新的子心流创建...")
|
||||||
await asyncio.sleep(60) # 每分钟检查一次是否有新的子心流
|
await asyncio.sleep(60) # 每分钟检查一次是否有新的子心流
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class Heartflow:
|
|||||||
await asyncio.sleep(300) # 5分钟思考一次
|
await asyncio.sleep(300) # 5分钟思考一次
|
||||||
|
|
||||||
async def do_a_thinking(self):
|
async def do_a_thinking(self):
|
||||||
logger.info("麦麦大脑袋转起来了")
|
logger.debug("麦麦大脑袋转起来了")
|
||||||
self.current_state.update_current_state_info()
|
self.current_state.update_current_state_info()
|
||||||
|
|
||||||
personality_info = self.personality_info
|
personality_info = self.personality_info
|
||||||
@@ -157,7 +157,7 @@ class Heartflow:
|
|||||||
asyncio.create_task(subheartflow.subheartflow_start_working())
|
asyncio.create_task(subheartflow.subheartflow_start_working())
|
||||||
logger.debug(f"创建异步任务 成功")
|
logger.debug(f"创建异步任务 成功")
|
||||||
self._subheartflows[subheartflow_id] = subheartflow
|
self._subheartflows[subheartflow_id] = subheartflow
|
||||||
logger.debug(f"添加 subheartflow 成功")
|
logger.info(f"添加 subheartflow 成功")
|
||||||
return self._subheartflows[subheartflow_id]
|
return self._subheartflows[subheartflow_id]
|
||||||
|
|
||||||
def get_subheartflow(self, observe_chat_id):
|
def get_subheartflow(self, observe_chat_id):
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class SubHeartflow:
|
|||||||
async def subheartflow_start_working(self):
|
async def subheartflow_start_working(self):
|
||||||
while True:
|
while True:
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
if current_time - self.last_reply_time > 180: # 3分钟 = 180秒
|
if current_time - self.last_reply_time > 120: # 120秒无回复/不在场,冻结
|
||||||
self.is_active = False
|
self.is_active = False
|
||||||
await asyncio.sleep(60) # 每60秒检查一次
|
await asyncio.sleep(60) # 每60秒检查一次
|
||||||
else:
|
else:
|
||||||
@@ -87,7 +87,7 @@ class SubHeartflow:
|
|||||||
self.last_active_time = current_time # 更新最后激活时间
|
self.last_active_time = current_time # 更新最后激活时间
|
||||||
|
|
||||||
observation = self.observations[0]
|
observation = self.observations[0]
|
||||||
observation.observe()
|
await observation.observe()
|
||||||
|
|
||||||
self.current_state.update_current_state_info()
|
self.current_state.update_current_state_info()
|
||||||
|
|
||||||
@@ -96,8 +96,8 @@ class SubHeartflow:
|
|||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
# 检查是否超过10分钟没有激活
|
# 检查是否超过10分钟没有激活
|
||||||
if current_time - self.last_active_time > 600: # 10分钟 = 600秒
|
if current_time - self.last_active_time > 600: # 5分钟无回复/不在场,销毁
|
||||||
logger.info(f"子心流 {self.subheartflow_id} 已经10分钟没有激活,正在销毁...")
|
logger.info(f"子心流 {self.subheartflow_id} 已经5分钟没有激活,正在销毁...")
|
||||||
break # 退出循环,销毁自己
|
break # 退出循环,销毁自己
|
||||||
|
|
||||||
async def do_a_thinking(self):
|
async def do_a_thinking(self):
|
||||||
@@ -146,7 +146,7 @@ class SubHeartflow:
|
|||||||
self.update_current_mind(reponse)
|
self.update_current_mind(reponse)
|
||||||
|
|
||||||
self.current_mind = reponse
|
self.current_mind = reponse
|
||||||
logger.info(f"prompt:\n{prompt}\n")
|
logger.debug(f"prompt:\n{prompt}\n")
|
||||||
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):
|
||||||
|
|||||||
Reference in New Issue
Block a user