style(chat): 统一 chat_loop 模块 logger 命名并添加业务注释
将各子模块 logger 由 hfc.* 缩减为统一 "hfc" 涉及的子模块: - cycle_tracker / energy_manager / hfc_utils / proactive_thinker / response_handler
This commit is contained in:
@@ -5,7 +5,7 @@ from src.common.logger import get_logger
|
|||||||
from src.chat.chat_loop.hfc_utils import CycleDetail
|
from src.chat.chat_loop.hfc_utils import CycleDetail
|
||||||
from .hfc_context import HfcContext
|
from .hfc_context import HfcContext
|
||||||
|
|
||||||
logger = get_logger("hfc.cycle")
|
logger = get_logger("hfc")
|
||||||
|
|
||||||
class CycleTracker:
|
class CycleTracker:
|
||||||
def __init__(self, context: HfcContext):
|
def __init__(self, context: HfcContext):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from src.config.config import global_config
|
|||||||
from src.plugin_system.base.component_types import ChatMode
|
from src.plugin_system.base.component_types import ChatMode
|
||||||
from .hfc_context import HfcContext
|
from .hfc_context import HfcContext
|
||||||
|
|
||||||
logger = get_logger("hfc.energy")
|
logger = get_logger("hfc")
|
||||||
|
|
||||||
class EnergyManager:
|
class EnergyManager:
|
||||||
def __init__(self, context: HfcContext):
|
def __init__(self, context: HfcContext):
|
||||||
|
|||||||
@@ -225,9 +225,9 @@ class HeartFChatting:
|
|||||||
if is_group_chat and global_config.chat.group_chat_mode == "focus":
|
if is_group_chat and global_config.chat.group_chat_mode == "focus":
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.context.energy_value <= 1:
|
if self.context.energy_value <= 1: # 如果能量值小于等于1(非强制情况)
|
||||||
self.context.energy_value = 1
|
self.context.energy_value = 1 # 将能量值设置为1
|
||||||
self.context.loop_mode = ChatMode.NORMAL
|
self.context.loop_mode = ChatMode.NORMAL # 切换到普通模式
|
||||||
|
|
||||||
def _check_focus_entry(self, new_message_count: int):
|
def _check_focus_entry(self, new_message_count: int):
|
||||||
"""
|
"""
|
||||||
@@ -254,11 +254,11 @@ class HeartFChatting:
|
|||||||
if is_group_chat and global_config.chat.group_chat_mode == "normal":
|
if is_group_chat and global_config.chat.group_chat_mode == "normal":
|
||||||
return
|
return
|
||||||
|
|
||||||
if global_config.chat.focus_value != 0:
|
if global_config.chat.focus_value != 0: # 如果专注值配置不为0(启用自动专注)
|
||||||
if new_message_count > 3 / pow(global_config.chat.focus_value, 0.5):
|
if new_message_count > 3 / pow(global_config.chat.focus_value, 0.5): # 如果新消息数超过阈值(基于专注值计算)
|
||||||
self.context.loop_mode = ChatMode.FOCUS
|
self.context.loop_mode = ChatMode.FOCUS # 进入专注模式
|
||||||
self.context.energy_value = 10 + (new_message_count / (3 / pow(global_config.chat.focus_value, 0.5))) * 10
|
self.context.energy_value = 10 + (new_message_count / (3 / pow(global_config.chat.focus_value, 0.5))) * 10 # 根据消息数量计算能量值
|
||||||
return
|
return # 返回,不再检查其他条件
|
||||||
|
|
||||||
if self.context.energy_value >= 30:
|
if self.context.energy_value >= 30: # 如果能量值达到或超过30
|
||||||
self.context.loop_mode = ChatMode.FOCUS
|
self.context.loop_mode = ChatMode.FOCUS # 进入专注模式
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from maim_message.message_base import GroupInfo
|
|||||||
|
|
||||||
from src.common.message_repository import count_messages
|
from src.common.message_repository import count_messages
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger("hfc")
|
||||||
|
|
||||||
|
|
||||||
class CycleDetail:
|
class CycleDetail:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from .hfc_context import HfcContext
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .cycle_processor import CycleProcessor
|
from .cycle_processor import CycleProcessor
|
||||||
|
|
||||||
logger = get_logger("hfc.proactive")
|
logger = get_logger("hfc")
|
||||||
|
|
||||||
class ProactiveThinker:
|
class ProactiveThinker:
|
||||||
def __init__(self, context: HfcContext, cycle_processor: "CycleProcessor"):
|
def __init__(self, context: HfcContext, cycle_processor: "CycleProcessor"):
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from src.plugin_system.apis import generator_api, send_api, message_api, databas
|
|||||||
from src.person_info.person_info import get_person_info_manager
|
from src.person_info.person_info import get_person_info_manager
|
||||||
from .hfc_context import HfcContext
|
from .hfc_context import HfcContext
|
||||||
|
|
||||||
logger = get_logger("hfc.response")
|
logger = get_logger("hfc")
|
||||||
|
|
||||||
class ResponseHandler:
|
class ResponseHandler:
|
||||||
def __init__(self, context: HfcContext):
|
def __init__(self, context: HfcContext):
|
||||||
|
|||||||
Reference in New Issue
Block a user