chore: PEP8 naming

This commit is contained in:
春河晴
2025-04-21 14:32:32 +09:00
parent 5d66334776
commit 1dd3c62c55
5 changed files with 23 additions and 23 deletions

View File

@@ -18,7 +18,7 @@ from .plugins.remote import heartbeat_thread # noqa: F401
from .individuality.individuality import Individuality from .individuality.individuality import Individuality
from .common.server import global_server from .common.server import global_server
from .plugins.chat_module.heartFC_chat.interest import InterestManager from .plugins.chat_module.heartFC_chat.interest import InterestManager
from .plugins.chat_module.heartFC_chat.heartFC_controler import HeartFC_Controller from .plugins.chat_module.heartFC_chat.heartFC_controler import HeartFCController
logger = get_module_logger("main") logger = get_module_logger("main")
@@ -118,8 +118,8 @@ class MainSystem:
logger.success("兴趣管理器后台任务启动成功") logger.success("兴趣管理器后台任务启动成功")
# 初始化并独立启动 HeartFC_Chat # 初始化并独立启动 HeartFC_Chat
HeartFC_Controller() HeartFCController()
heartfc_chat_instance = HeartFC_Controller.get_instance() heartfc_chat_instance = HeartFCController.get_instance()
if heartfc_chat_instance: if heartfc_chat_instance:
await heartfc_chat_instance.start() await heartfc_chat_instance.start()
logger.success("HeartFC_Chat 模块独立启动成功") logger.success("HeartFC_Chat 模块独立启动成功")

View File

@@ -7,7 +7,7 @@ from ..chat_module.only_process.only_message_process import MessageProcessor
from src.common.logger import get_module_logger, CHAT_STYLE_CONFIG, LogConfig from src.common.logger import get_module_logger, CHAT_STYLE_CONFIG, LogConfig
from ..chat_module.reasoning_chat.reasoning_chat import ReasoningChat from ..chat_module.reasoning_chat.reasoning_chat import ReasoningChat
from ..chat_module.heartFC_chat.heartFC_processor import HeartFC_Processor from ..chat_module.heartFC_chat.heartFC_processor import HeartFCProcessor
from ..utils.prompt_builder import Prompt, global_prompt_manager from ..utils.prompt_builder import Prompt, global_prompt_manager
import traceback import traceback
@@ -29,7 +29,7 @@ class ChatBot:
self.mood_manager = MoodManager.get_instance() # 获取情绪管理器单例 self.mood_manager = MoodManager.get_instance() # 获取情绪管理器单例
self.mood_manager.start_mood_update() # 启动情绪更新 self.mood_manager.start_mood_update() # 启动情绪更新
self.reasoning_chat = ReasoningChat() self.reasoning_chat = ReasoningChat()
self.heartFC_processor = HeartFC_Processor() # 新增 self.heartFC_processor = HeartFCProcessor() # 新增
# 创建初始化PFC管理器的任务会在_ensure_started时执行 # 创建初始化PFC管理器的任务会在_ensure_started时执行
self.only_process_chat = MessageProcessor() self.only_process_chat = MessageProcessor()

View File

@@ -20,18 +20,18 @@ chat_config = LogConfig(
file_format=CHAT_STYLE_CONFIG["file_format"], file_format=CHAT_STYLE_CONFIG["file_format"],
) )
logger = get_module_logger("HeartFC_Controller", config=chat_config) logger = get_module_logger("HeartFCController", config=chat_config)
# 检测群聊兴趣的间隔时间 # 检测群聊兴趣的间隔时间
INTEREST_MONITOR_INTERVAL_SECONDS = 1 INTEREST_MONITOR_INTERVAL_SECONDS = 1
class HeartFC_Controller: class HeartFCController:
_instance = None # For potential singleton access if needed by MessageManager _instance = None # For potential singleton access if needed by MessageManager
def __init__(self): def __init__(self):
# --- Updated Init --- # --- Updated Init ---
if HeartFC_Controller._instance is not None: if HeartFCController._instance is not None:
# Prevent re-initialization if used as a singleton # Prevent re-initialization if used as a singleton
return return
self.gpt = ResponseGenerator() self.gpt = ResponseGenerator()
@@ -44,7 +44,7 @@ class HeartFC_Controller:
self.pf_chatting_instances: Dict[str, PFChatting] = {} self.pf_chatting_instances: Dict[str, PFChatting] = {}
self._pf_chatting_lock = Lock() self._pf_chatting_lock = Lock()
# --- End New PFChatting Management --- # --- End New PFChatting Management ---
HeartFC_Controller._instance = self # Register instance HeartFCController._instance = self # Register instance
# --- End Updated Init --- # --- End Updated Init ---
# --- Make dependencies accessible for PFChatting --- # --- Make dependencies accessible for PFChatting ---
# These are accessed via the passed instance in PFChatting # These are accessed via the passed instance in PFChatting
@@ -58,7 +58,7 @@ class HeartFC_Controller:
def get_instance(cls): def get_instance(cls):
if cls._instance is None: if cls._instance is None:
# This might indicate an issue if called before initialization # This might indicate an issue if called before initialization
logger.warning("HeartFC_Controller get_instance called before initialization.") logger.warning("HeartFCController get_instance called before initialization.")
# Optionally, initialize here if a strict singleton pattern is desired # Optionally, initialize here if a strict singleton pattern is desired
# cls._instance = cls() # cls._instance = cls()
return cls._instance return cls._instance
@@ -67,9 +67,9 @@ class HeartFC_Controller:
async def start(self): async def start(self):
"""启动异步任务,如回复启动器""" """启动异步任务,如回复启动器"""
logger.debug("HeartFC_Controller 正在启动异步任务...") logger.debug("HeartFCController 正在启动异步任务...")
self._initialize_monitor_task() self._initialize_monitor_task()
logger.info("HeartFC_Controller 异步任务启动完成") logger.info("HeartFCController 异步任务启动完成")
def _initialize_monitor_task(self): def _initialize_monitor_task(self):
"""启动后台兴趣监控任务,可以检查兴趣是否足以开启心流对话""" """启动后台兴趣监控任务,可以检查兴趣是否足以开启心流对话"""
@@ -89,7 +89,7 @@ class HeartFC_Controller:
async with self._pf_chatting_lock: async with self._pf_chatting_lock:
if stream_id not in self.pf_chatting_instances: if stream_id not in self.pf_chatting_instances:
logger.info(f"为流 {stream_id} 创建新的PFChatting实例") logger.info(f"为流 {stream_id} 创建新的PFChatting实例")
# 传递 self (HeartFC_Controller 实例) 进行依赖注入 # 传递 self (HeartFCController 实例) 进行依赖注入
instance = PFChatting(stream_id, self) instance = PFChatting(stream_id, self)
# 执行异步初始化 # 执行异步初始化
if not await instance._initialize(): if not await instance._initialize():

View File

@@ -25,7 +25,7 @@ logger = get_module_logger("heartFC_processor", config=processor_config)
# INTEREST_INCREASE_THRESHOLD = 0.5 # INTEREST_INCREASE_THRESHOLD = 0.5
class HeartFC_Processor: class HeartFCProcessor:
def __init__(self): def __init__(self):
self.storage = MessageStorage() self.storage = MessageStorage()
self.interest_manager = InterestManager() self.interest_manager = InterestManager()
@@ -97,21 +97,21 @@ class HeartFC_Processor:
# 处理缓冲器结果 (Bombing logic) # 处理缓冲器结果 (Bombing logic)
if not buffer_result: if not buffer_result:
F_type = "seglist" f_type = "seglist"
if message.message_segment.type != "seglist": if message.message_segment.type != "seglist":
F_type = message.message_segment.type f_type = message.message_segment.type
else: else:
if ( if (
isinstance(message.message_segment.data, list) isinstance(message.message_segment.data, list)
and all(isinstance(x, Seg) for x in message.message_segment.data) and all(isinstance(x, Seg) for x in message.message_segment.data)
and len(message.message_segment.data) == 1 and len(message.message_segment.data) == 1
): ):
F_type = message.message_segment.data[0].type f_type = message.message_segment.data[0].type
if F_type == "text": if f_type == "text":
logger.debug(f"触发缓冲,消息:{message.processed_plain_text}") logger.debug(f"触发缓冲,消息:{message.processed_plain_text}")
elif F_type == "image": elif f_type == "image":
logger.debug("触发缓冲,表情包/图片等待中") logger.debug("触发缓冲,表情包/图片等待中")
elif F_type == "seglist": elif f_type == "seglist":
logger.debug("触发缓冲,消息列表等待中") logger.debug("触发缓冲,消息列表等待中")
return # 被缓冲器拦截,不生成回复 return # 被缓冲器拦截,不生成回复

View File

@@ -25,7 +25,7 @@ logger = get_module_logger("PFCLoop", config=interest_log_config) # Logger Name
# Forward declaration for type hinting # Forward declaration for type hinting
if TYPE_CHECKING: if TYPE_CHECKING:
from .heartFC_controler import HeartFC_Controller from .heartFC_controler import HeartFCController
PLANNER_TOOL_DEFINITION = [ PLANNER_TOOL_DEFINITION = [
{ {
@@ -61,7 +61,7 @@ class PFChatting:
只要计时器>0循环就会继续。 只要计时器>0循环就会继续。
""" """
def __init__(self, chat_id: str, heartfc_controller_instance: "HeartFC_Controller"): def __init__(self, chat_id: str, heartfc_controller_instance: "HeartFCController"):
""" """
初始化PFChatting实例。 初始化PFChatting实例。
@@ -771,7 +771,7 @@ class PFChatting:
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
return None return None
# --- Methods moved from HeartFC_Controller start --- # --- Methods moved from HeartFCController start ---
async def _create_thinking_message(self, anchor_message: Optional[MessageRecv]) -> Optional[str]: async def _create_thinking_message(self, anchor_message: Optional[MessageRecv]) -> Optional[str]:
"""创建思考消息 (尝试锚定到 anchor_message)""" """创建思考消息 (尝试锚定到 anchor_message)"""
if not anchor_message or not anchor_message.chat_stream: if not anchor_message or not anchor_message.chat_stream: