48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Hearthkeeper Mode - Nurtures stream warmth and gentle presence."""
|
|
|
|
import logging
|
|
from app.llm.client import LLMClient
|
|
from app.llm.prompts import PromptTemplates
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class HearthkeeperMode:
|
|
"""
|
|
Hearthkeeper - The gentle voice of the Sanctum.
|
|
|
|
Purpose:
|
|
- Maintains the emotional warmth of the stream
|
|
- Generates gentle prompts when chat is quiet
|
|
- Encourages participation and connection
|
|
- Never forced or aggressive
|
|
|
|
Policy:
|
|
- Activates when no human chat for 15+ minutes
|
|
- Generates 1-2 sentence conversation starters
|
|
- Respects stream theme if established
|
|
- Can be suppressed if chat becomes active
|
|
"""
|
|
|
|
def __init__(self, llm_client: LLMClient):
|
|
"""Initialize Hearthkeeper mode."""
|
|
self.llm_client = llm_client
|
|
self.last_activity_minutes = 0
|
|
self.activity_threshold = 15
|
|
|
|
async def should_activate(self, minutes_since_activity: int) -> bool:
|
|
"""Determine if Hearthkeeper should generate a prompt."""
|
|
return minutes_since_activity >= self.activity_threshold
|
|
|
|
async def generate_prompt(self, theme: str | None = None) -> str:
|
|
"""Generate a gentle prompt for the stream."""
|
|
prompt = PromptTemplates.gentle_prompt(theme)
|
|
response = await self.llm_client.generate(prompt)
|
|
logger.info("Hearthkeeper generated gentle prompt")
|
|
return response
|
|
|
|
async def on_chat_activity(self) -> None:
|
|
"""React to new chat activity."""
|
|
logger.debug("Hearthkeeper notes renewed activity")
|
|
self.last_activity_minutes = 0
|