🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -368,7 +368,6 @@ class SubHeartflow:
|
|||||||
return self.normal_chat_instance.get_action_manager()
|
return self.normal_chat_instance.get_action_manager()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def get_full_state(self) -> dict:
|
async def get_full_state(self) -> dict:
|
||||||
"""获取子心流的完整状态,包括兴趣、思维和聊天状态。"""
|
"""获取子心流的完整状态,包括兴趣、思维和聊天状态。"""
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -191,7 +191,6 @@ class MessageManager:
|
|||||||
container = await self.get_container(chat_stream.stream_id)
|
container = await self.get_container(chat_stream.stream_id)
|
||||||
container.add_message(message)
|
container.add_message(message)
|
||||||
|
|
||||||
|
|
||||||
async def _handle_sending_message(self, container: MessageContainer, message: MessageSending):
|
async def _handle_sending_message(self, container: MessageContainer, message: MessageSending):
|
||||||
"""处理单个 MessageSending 消息 (包含 set_reply 逻辑)"""
|
"""处理单个 MessageSending 消息 (包含 set_reply 逻辑)"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -489,7 +489,6 @@ class NormalChat:
|
|||||||
f"[{self.stream_name}] 从队列中取出消息进行处理: User {message.message_info.user_info.user_id}, Time: {time.strftime('%H:%M:%S', time.localtime(message.message_info.time))}"
|
f"[{self.stream_name}] 从队列中取出消息进行处理: User {message.message_info.user_info.user_id}, Time: {time.strftime('%H:%M:%S', time.localtime(message.message_info.time))}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# 检查是否有用户满足关系构建条件
|
# 检查是否有用户满足关系构建条件
|
||||||
asyncio.create_task(self._check_relation_building_conditions(message))
|
asyncio.create_task(self._check_relation_building_conditions(message))
|
||||||
|
|
||||||
@@ -717,7 +716,6 @@ class NormalChat:
|
|||||||
self.priority_manager.add_message(message)
|
self.priority_manager.add_message(message)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# 新增:在auto模式下检查是否需要直接切换到focus模式
|
# 新增:在auto模式下检查是否需要直接切换到focus模式
|
||||||
if global_config.chat.chat_mode == "auto":
|
if global_config.chat.chat_mode == "auto":
|
||||||
if await self._check_should_switch_to_focus():
|
if await self._check_should_switch_to_focus():
|
||||||
@@ -742,8 +740,6 @@ class NormalChat:
|
|||||||
if self._disabled:
|
if self._disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 检查是否有用户满足关系构建条件
|
# 检查是否有用户满足关系构建条件
|
||||||
asyncio.create_task(self._check_relation_building_conditions(message))
|
asyncio.create_task(self._check_relation_building_conditions(message))
|
||||||
|
|
||||||
@@ -800,7 +796,6 @@ class NormalChat:
|
|||||||
do_reply = await self.reply_one_message(message)
|
do_reply = await self.reply_one_message(message)
|
||||||
response_set = do_reply if do_reply else None
|
response_set = do_reply if do_reply else None
|
||||||
|
|
||||||
|
|
||||||
# 输出性能计时结果
|
# 输出性能计时结果
|
||||||
if do_reply and response_set: # 确保 response_set 不是 None
|
if do_reply and response_set: # 确保 response_set 不是 None
|
||||||
timing_str = " | ".join([f"{step}: {duration:.2f}秒" for step, duration in timing_results.items()])
|
timing_str = " | ".join([f"{step}: {duration:.2f}秒" for step, duration in timing_results.items()])
|
||||||
@@ -852,7 +847,6 @@ class NormalChat:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
no_action = {
|
no_action = {
|
||||||
"action_result": {
|
"action_result": {
|
||||||
"action_type": "no_action",
|
"action_type": "no_action",
|
||||||
@@ -921,10 +915,14 @@ class NormalChat:
|
|||||||
)
|
)
|
||||||
response_set, plan_result = results
|
response_set, plan_result = results
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logger.warning(f"[{self.stream_name}] 并行执行回复生成和动作规划超时 ({gather_timeout}秒),正在取消相关任务...")
|
logger.warning(
|
||||||
|
f"[{self.stream_name}] 并行执行回复生成和动作规划超时 ({gather_timeout}秒),正在取消相关任务..."
|
||||||
|
)
|
||||||
self.timeout_count += 1
|
self.timeout_count += 1
|
||||||
if self.timeout_count > 5:
|
if self.timeout_count > 5:
|
||||||
logger.error(f"[{self.stream_name}] 连续回复超时,{global_config.normal_chat.thinking_timeout}秒 内大模型没有返回有效内容,请检查你的api是否速度过慢或配置错误。建议不要使用推理模型,推理模型生成速度过慢。")
|
logger.error(
|
||||||
|
f"[{self.stream_name}] 连续回复超时,{global_config.normal_chat.thinking_timeout}秒 内大模型没有返回有效内容,请检查你的api是否速度过慢或配置错误。建议不要使用推理模型,推理模型生成速度过慢。"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# 取消未完成的任务
|
# 取消未完成的任务
|
||||||
|
|||||||
@@ -53,6 +53,5 @@ class ClassicalWillingManager(BaseWillingManager):
|
|||||||
if current_willing < 1:
|
if current_willing < 1:
|
||||||
self.chat_reply_willing[chat_id] = min(1.0, current_willing + 0.4)
|
self.chat_reply_willing[chat_id] = min(1.0, current_willing + 0.4)
|
||||||
|
|
||||||
|
|
||||||
async def not_reply_handle(self, message_id):
|
async def not_reply_handle(self, message_id):
|
||||||
return await super().not_reply_handle(message_id)
|
return await super().not_reply_handle(message_id)
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ class BaseWillingManager(ABC):
|
|||||||
"""抽象方法:获取回复概率"""
|
"""抽象方法:获取回复概率"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
async def get_willing(self, chat_id: str):
|
async def get_willing(self, chat_id: str):
|
||||||
"""获取指定聊天流的回复意愿"""
|
"""获取指定聊天流的回复意愿"""
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ class NormalChatConfig(ConfigBase):
|
|||||||
response_interested_rate_amplifier: float = 1.0
|
response_interested_rate_amplifier: float = 1.0
|
||||||
"""回复兴趣度放大系数"""
|
"""回复兴趣度放大系数"""
|
||||||
|
|
||||||
|
|
||||||
mentioned_bot_inevitable_reply: bool = False
|
mentioned_bot_inevitable_reply: bool = False
|
||||||
"""提及 bot 必然回复"""
|
"""提及 bot 必然回复"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user