mirror of https://github.com/Mai-with-u/MaiBot.git
import优化+1
parent
f9cc1d96be
commit
471b357269
|
|
@ -1,6 +1,5 @@
|
||||||
import time
|
import time
|
||||||
from random import random
|
from random import random
|
||||||
import re
|
|
||||||
import traceback
|
import traceback
|
||||||
from typing import List
|
from typing import List
|
||||||
from ...memory_system.Hippocampus import HippocampusManager
|
from ...memory_system.Hippocampus import HippocampusManager
|
||||||
|
|
@ -61,10 +60,10 @@ class ThinkFlowChat:
|
||||||
|
|
||||||
return thinking_id
|
return thinking_id
|
||||||
|
|
||||||
async def _send_response_messages(self,
|
async def _send_response_messages(self,
|
||||||
message,
|
message,
|
||||||
chat,
|
chat,
|
||||||
response_set:List[str],
|
response_set:List[str],
|
||||||
thinking_id) -> MessageSending:
|
thinking_id) -> MessageSending:
|
||||||
"""发送回复消息"""
|
"""发送回复消息"""
|
||||||
container = message_manager.get_container(chat.stream_id)
|
container = message_manager.get_container(chat.stream_id)
|
||||||
|
|
@ -266,8 +265,8 @@ class ThinkFlowChat:
|
||||||
if random() < reply_probability:
|
if random() < reply_probability:
|
||||||
try:
|
try:
|
||||||
do_reply = True
|
do_reply = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 创建思考消息
|
# 创建思考消息
|
||||||
try:
|
try:
|
||||||
|
|
@ -277,9 +276,9 @@ class ThinkFlowChat:
|
||||||
timing_results["创建思考消息"] = timer2 - timer1
|
timing_results["创建思考消息"] = timer2 - timer1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"心流创建思考消息失败: {e}")
|
logger.error(f"心流创建思考消息失败: {e}")
|
||||||
|
|
||||||
logger.debug(f"创建捕捉器,thinking_id:{thinking_id}")
|
logger.debug(f"创建捕捉器,thinking_id:{thinking_id}")
|
||||||
|
|
||||||
info_catcher = info_catcher_manager.get_info_catcher(thinking_id)
|
info_catcher = info_catcher_manager.get_info_catcher(thinking_id)
|
||||||
info_catcher.catch_decide_to_response(message)
|
info_catcher.catch_decide_to_response(message)
|
||||||
|
|
||||||
|
|
@ -291,7 +290,7 @@ class ThinkFlowChat:
|
||||||
timing_results["观察"] = timer2 - timer1
|
timing_results["观察"] = timer2 - timer1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"心流观察失败: {e}")
|
logger.error(f"心流观察失败: {e}")
|
||||||
|
|
||||||
info_catcher.catch_after_observe(timing_results["观察"])
|
info_catcher.catch_after_observe(timing_results["观察"])
|
||||||
|
|
||||||
# 思考前脑内状态
|
# 思考前脑内状态
|
||||||
|
|
@ -306,7 +305,7 @@ class ThinkFlowChat:
|
||||||
timing_results["思考前脑内状态"] = timer2 - timer1
|
timing_results["思考前脑内状态"] = timer2 - timer1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"心流思考前脑内状态失败: {e}")
|
logger.error(f"心流思考前脑内状态失败: {e}")
|
||||||
|
|
||||||
info_catcher.catch_afer_shf_step(timing_results["思考前脑内状态"],past_mind,current_mind)
|
info_catcher.catch_afer_shf_step(timing_results["思考前脑内状态"],past_mind,current_mind)
|
||||||
|
|
||||||
# 生成回复
|
# 生成回复
|
||||||
|
|
@ -316,7 +315,7 @@ class ThinkFlowChat:
|
||||||
timing_results["生成回复"] = timer2 - timer1
|
timing_results["生成回复"] = timer2 - timer1
|
||||||
|
|
||||||
info_catcher.catch_after_generate_response(timing_results["生成回复"])
|
info_catcher.catch_after_generate_response(timing_results["生成回复"])
|
||||||
|
|
||||||
if not response_set:
|
if not response_set:
|
||||||
logger.info("回复生成失败,返回为空")
|
logger.info("回复生成失败,返回为空")
|
||||||
return
|
return
|
||||||
|
|
@ -329,11 +328,11 @@ class ThinkFlowChat:
|
||||||
timing_results["发送消息"] = timer2 - timer1
|
timing_results["发送消息"] = timer2 - timer1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"心流发送消息失败: {e}")
|
logger.error(f"心流发送消息失败: {e}")
|
||||||
|
|
||||||
|
|
||||||
info_catcher.catch_after_response(timing_results["发送消息"],response_set,first_bot_msg)
|
info_catcher.catch_after_response(timing_results["发送消息"],response_set,first_bot_msg)
|
||||||
|
|
||||||
|
|
||||||
info_catcher.done_catch()
|
info_catcher.done_catch()
|
||||||
|
|
||||||
# 处理表情包
|
# 处理表情包
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue