ruff
This commit is contained in:
@@ -292,7 +292,7 @@ class HeartFChatting:
|
|||||||
async with global_prompt_manager.async_message_scope(self.chat_stream.context.get_template_name()):
|
async with global_prompt_manager.async_message_scope(self.chat_stream.context.get_template_name()):
|
||||||
logger.debug(f"模板 {self.chat_stream.context.get_template_name()}")
|
logger.debug(f"模板 {self.chat_stream.context.get_template_name()}")
|
||||||
loop_info = await self._observe_process_plan_action_loop(cycle_timers, thinking_id)
|
loop_info = await self._observe_process_plan_action_loop(cycle_timers, thinking_id)
|
||||||
|
|
||||||
print(loop_info["loop_action_info"]["command"])
|
print(loop_info["loop_action_info"]["command"])
|
||||||
if loop_info["loop_action_info"]["command"] == "stop_focus_chat":
|
if loop_info["loop_action_info"]["command"] == "stop_focus_chat":
|
||||||
logger.info(f"{self.log_prefix} 麦麦决定停止专注聊天")
|
logger.info(f"{self.log_prefix} 麦麦决定停止专注聊天")
|
||||||
@@ -441,7 +441,7 @@ class HeartFChatting:
|
|||||||
observations.append(self.working_observation)
|
observations.append(self.working_observation)
|
||||||
observations.append(self.hfcloop_observation)
|
observations.append(self.hfcloop_observation)
|
||||||
observations.append(self.structure_observation)
|
observations.append(self.structure_observation)
|
||||||
|
|
||||||
loop_observation_info = {
|
loop_observation_info = {
|
||||||
"observations": observations,
|
"observations": observations,
|
||||||
}
|
}
|
||||||
@@ -562,10 +562,12 @@ class HeartFChatting:
|
|||||||
result = await action_handler.handle_action()
|
result = await action_handler.handle_action()
|
||||||
if len(result) == 3:
|
if len(result) == 3:
|
||||||
success, reply_text, command = result
|
success, reply_text, command = result
|
||||||
else:
|
else:
|
||||||
success, reply_text = result
|
success, reply_text = result
|
||||||
command = ""
|
command = ""
|
||||||
logger.info(f"{self.log_prefix} 麦麦决定'{action}', 原因'{reasoning}',返回结果'{success}', '{reply_text}', '{command}'")
|
logger.info(
|
||||||
|
f"{self.log_prefix} 麦麦决定'{action}', 原因'{reasoning}',返回结果'{success}', '{reply_text}', '{command}'"
|
||||||
|
)
|
||||||
return success, reply_text, command
|
return success, reply_text, command
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ class ActionProcessor(BaseProcessor):
|
|||||||
reply_sequence.append(action_type == "reply")
|
reply_sequence.append(action_type == "reply")
|
||||||
|
|
||||||
# 检查no_reply比例
|
# 检查no_reply比例
|
||||||
if len(recent_cycles) >= (5 * global_config.focus_chat.exit_focus_threshold) and (no_reply_count / len(recent_cycles)) >= (0.75 * global_config.focus_chat.exit_focus_threshold):
|
if len(recent_cycles) >= (5 * global_config.focus_chat.exit_focus_threshold) and (
|
||||||
|
no_reply_count / len(recent_cycles)
|
||||||
|
) >= (0.75 * global_config.focus_chat.exit_focus_threshold):
|
||||||
if global_config.chat.chat_mode == "auto":
|
if global_config.chat.chat_mode == "auto":
|
||||||
result["add"].append("exit_focus_chat")
|
result["add"].append("exit_focus_chat")
|
||||||
result["remove"].append("no_reply")
|
result["remove"].append("no_reply")
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ class ActionManager:
|
|||||||
"""
|
"""
|
||||||
# 检查动作是否在当前使用的动作集中
|
# 检查动作是否在当前使用的动作集中
|
||||||
# if action_name not in self._using_actions:
|
# if action_name not in self._using_actions:
|
||||||
# logger.warning(f"当前不可用的动作类型: {action_name}")
|
# logger.warning(f"当前不可用的动作类型: {action_name}")
|
||||||
# return None
|
# return None
|
||||||
|
|
||||||
handler_class = _ACTION_REGISTRY.get(action_name)
|
handler_class = _ACTION_REGISTRY.get(action_name)
|
||||||
if not handler_class:
|
if not handler_class:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from src.config.config import global_config
|
|
||||||
from typing import Optional, Dict
|
from typing import Optional, Dict
|
||||||
import traceback
|
import traceback
|
||||||
from src.common.logger_manager import get_logger
|
from src.common.logger_manager import get_logger
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ class SubHeartflow:
|
|||||||
if self.normal_chat_instance:
|
if self.normal_chat_instance:
|
||||||
return self.normal_chat_instance.get_recent_replies(limit)
|
return self.normal_chat_instance.get_recent_replies(limit)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def add_interest_message(self, message: MessageRecv, interest_value: float, is_mentioned: bool):
|
def add_interest_message(self, message: MessageRecv, interest_value: float, is_mentioned: bool):
|
||||||
self.interest_dict[message.message_info.message_id] = (message, interest_value, is_mentioned)
|
self.interest_dict[message.message_info.message_id] = (message, interest_value, is_mentioned)
|
||||||
# 如果字典长度超过10,删除最旧的消息
|
# 如果字典长度超过10,删除最旧的消息
|
||||||
@@ -361,7 +361,6 @@ class SubHeartflow:
|
|||||||
await self._stop_normal_chat()
|
await self._stop_normal_chat()
|
||||||
await self._stop_heart_fc_chat()
|
await self._stop_heart_fc_chat()
|
||||||
|
|
||||||
|
|
||||||
# 取消可能存在的旧后台任务 (self.task)
|
# 取消可能存在的旧后台任务 (self.task)
|
||||||
if self.task and not self.task.done():
|
if self.task and not self.task.done():
|
||||||
logger.debug(f"{self.log_prefix} 取消子心流主任务 (Shutdown)...")
|
logger.debug(f"{self.log_prefix} 取消子心流主任务 (Shutdown)...")
|
||||||
|
|||||||
Reference in New Issue
Block a user