feat(chat): implement sleep pressure and insomnia system
This commit introduces a new sleep pressure and insomnia system to simulate more realistic character behavior. Key features include: - **Sleep Pressure**: A new metric that accumulates with each action the bot takes and decreases during scheduled sleep times. - **Insomnia Mechanic**: When a sleep period begins, the system checks the current sleep pressure. Low pressure can lead to a higher chance of "insomnia," causing the bot to stay awake. There is also a small chance for random insomnia. - **Insomnia State**: During insomnia, the bot enters a special state for a configurable duration. It can trigger unique proactive thoughts related to being unable to sleep, and its mood is adjusted accordingly. - **Configuration**: All parameters, such as insomnia probability, duration, and pressure thresholds, are fully configurable.
This commit is contained in:
@@ -9,6 +9,7 @@ from src.chat.chat_loop.hfc_utils import CycleDetail
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .wakeup_manager import WakeUpManager
|
||||
from .energy_manager import EnergyManager
|
||||
|
||||
class HfcContext:
|
||||
def __init__(self, chat_id: str):
|
||||
@@ -40,6 +41,12 @@ class HfcContext:
|
||||
|
||||
self.loop_mode = ChatMode.NORMAL
|
||||
self.energy_value = 5.0
|
||||
self.sleep_pressure = 0.0
|
||||
self.was_sleeping = False # 用于检测睡眠状态的切换
|
||||
|
||||
# 失眠状态
|
||||
self.is_in_insomnia: bool = False
|
||||
self.insomnia_end_time: float = 0.0
|
||||
|
||||
self.last_message_time = time.time()
|
||||
self.last_read_time = time.time() - 10
|
||||
@@ -53,4 +60,5 @@ class HfcContext:
|
||||
self.current_cycle_detail: Optional[CycleDetail] = None
|
||||
|
||||
# 唤醒度管理器 - 延迟初始化以避免循环导入
|
||||
self.wakeup_manager: Optional['WakeUpManager'] = None
|
||||
self.wakeup_manager: Optional['WakeUpManager'] = None
|
||||
self.energy_manager: Optional['EnergyManager'] = None
|
||||
Reference in New Issue
Block a user