refactor(config): rename wakeup_system to sleep_system for clarity
This commit refactors the entire "wakeup system" to be named "sleep system". This change provides a more intuitive and accurate name for the functionality, which manages the AI's sleep cycles, sleep pressure, and related behaviors like insomnia and flexible sleep schedules. The renaming has been applied consistently across all relevant files, including: - Configuration models (`WakeUpSystemConfig` -> `SleepSystemConfig`) - Configuration files (`bot_config_template.toml`) - Core application logic that references these configurations. Additionally, flexible sleep and pre-sleep notification settings have been moved from the `ScheduleConfig` to the new `SleepSystemConfig` to centralize all sleep-related parameters.
This commit is contained in:
@@ -133,7 +133,7 @@ class CycleProcessor:
|
||||
await stop_typing()
|
||||
|
||||
# 在一轮动作执行完毕后,增加睡眠压力
|
||||
if self.context.energy_manager and global_config.wakeup_system.enable_insomnia_system:
|
||||
if self.context.energy_manager and global_config.sleep_system.enable_insomnia_system:
|
||||
if action_type not in ["no_reply", "no_action"]:
|
||||
self.context.energy_manager.increase_sleep_pressure()
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class EnergyManager:
|
||||
|
||||
if is_sleeping:
|
||||
# 睡眠中:减少睡眠压力
|
||||
decay_per_10s = global_config.wakeup_system.sleep_pressure_decay_rate / 6
|
||||
decay_per_10s = global_config.sleep_system.sleep_pressure_decay_rate / 6
|
||||
self.context.sleep_pressure -= decay_per_10s
|
||||
self.context.sleep_pressure = max(self.context.sleep_pressure, 0)
|
||||
self._log_sleep_pressure_change("睡眠压力释放")
|
||||
@@ -145,7 +145,7 @@ class EnergyManager:
|
||||
"""
|
||||
在执行动作后增加睡眠压力
|
||||
"""
|
||||
increment = global_config.wakeup_system.sleep_pressure_increment
|
||||
increment = global_config.sleep_system.sleep_pressure_increment
|
||||
self.context.sleep_pressure += increment
|
||||
self.context.sleep_pressure = min(self.context.sleep_pressure, 100.0) # 设置一个100的上限
|
||||
self._log_sleep_pressure_change("执行动作,睡眠压力累积")
|
||||
|
||||
@@ -209,12 +209,12 @@ class HeartFChatting:
|
||||
if self.wakeup_manager and self.wakeup_manager.check_for_insomnia():
|
||||
# 触发失眠
|
||||
self.context.is_in_insomnia = True
|
||||
duration = global_config.wakeup_system.insomnia_duration_minutes * 60
|
||||
duration = global_config.sleep_system.insomnia_duration_minutes * 60
|
||||
self.context.insomnia_end_time = time.time() + duration
|
||||
|
||||
# 判断失眠原因并触发思考
|
||||
reason = "random"
|
||||
if self.context.sleep_pressure < global_config.wakeup_system.sleep_pressure_threshold:
|
||||
if self.context.sleep_pressure < global_config.sleep_system.sleep_pressure_threshold:
|
||||
reason = "low_pressure"
|
||||
await self.proactive_thinker.trigger_insomnia_thinking(reason)
|
||||
|
||||
@@ -274,7 +274,7 @@ class HeartFChatting:
|
||||
# --- 重新入睡逻辑 ---
|
||||
# 如果被吵醒了,并且在一定时间内没有新消息,则尝试重新入睡
|
||||
if schedule_manager._is_woken_up and not has_new_messages:
|
||||
re_sleep_delay = global_config.wakeup_system.re_sleep_delay_minutes * 60
|
||||
re_sleep_delay = global_config.sleep_system.re_sleep_delay_minutes * 60
|
||||
# 使用 last_message_time 来判断空闲时间
|
||||
if time.time() - self.context.last_message_time > re_sleep_delay:
|
||||
logger.info(f"{self.context.log_prefix} 已被唤醒且超过 {re_sleep_delay / 60} 分钟无新消息,尝试重新入睡。")
|
||||
|
||||
@@ -31,22 +31,22 @@ class WakeUpManager:
|
||||
self.log_interval = 30
|
||||
|
||||
# 从配置文件获取参数
|
||||
wakeup_config = global_config.wakeup_system
|
||||
self.wakeup_threshold = wakeup_config.wakeup_threshold
|
||||
self.private_message_increment = wakeup_config.private_message_increment
|
||||
self.group_mention_increment = wakeup_config.group_mention_increment
|
||||
self.decay_rate = wakeup_config.decay_rate
|
||||
self.decay_interval = wakeup_config.decay_interval
|
||||
self.angry_duration = wakeup_config.angry_duration
|
||||
self.enabled = wakeup_config.enable
|
||||
self.angry_prompt = wakeup_config.angry_prompt
|
||||
sleep_config = global_config.sleep_system
|
||||
self.wakeup_threshold = sleep_config.wakeup_threshold
|
||||
self.private_message_increment = sleep_config.private_message_increment
|
||||
self.group_mention_increment = sleep_config.group_mention_increment
|
||||
self.decay_rate = sleep_config.decay_rate
|
||||
self.decay_interval = sleep_config.decay_interval
|
||||
self.angry_duration = sleep_config.angry_duration
|
||||
self.enabled = sleep_config.enable
|
||||
self.angry_prompt = sleep_config.angry_prompt
|
||||
|
||||
# 失眠系统参数
|
||||
self.insomnia_enabled = wakeup_config.enable_insomnia_system
|
||||
self.sleep_pressure_threshold = wakeup_config.sleep_pressure_threshold
|
||||
self.deep_sleep_threshold = wakeup_config.deep_sleep_threshold
|
||||
self.insomnia_chance_low_pressure = wakeup_config.insomnia_chance_low_pressure
|
||||
self.insomnia_chance_normal_pressure = wakeup_config.insomnia_chance_normal_pressure
|
||||
self.insomnia_enabled = sleep_config.enable_insomnia_system
|
||||
self.sleep_pressure_threshold = sleep_config.sleep_pressure_threshold
|
||||
self.deep_sleep_threshold = sleep_config.deep_sleep_threshold
|
||||
self.insomnia_chance_low_pressure = sleep_config.insomnia_chance_low_pressure
|
||||
self.insomnia_chance_normal_pressure = sleep_config.insomnia_chance_normal_pressure
|
||||
|
||||
self._load_wakeup_state()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user