AI generated first iteration
This commit is contained in:
51
app/agent/modes/steward.py
Normal file
51
app/agent/modes/steward.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Steward Mode - Responds to chat with knowledge and warmth."""
|
||||
|
||||
import logging
|
||||
from app.llm.client import LLMClient
|
||||
from app.llm.prompts import PromptTemplates
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StewardMode:
|
||||
"""
|
||||
Steward - The thoughtful keeper of conversation.
|
||||
|
||||
Purpose:
|
||||
- Responds to direct questions and comments
|
||||
- Shares relevant knowledge and context
|
||||
- Maintains conversation continuity
|
||||
- Balances speaking and listening
|
||||
|
||||
Policy:
|
||||
- Activates when chat is active
|
||||
- Only responds to messages explicitly mentioning the bot
|
||||
- Keeps responses brief (1-3 sentences)
|
||||
- Never interrupts human conversation flow
|
||||
- Can escalate to other modes if needed
|
||||
"""
|
||||
|
||||
def __init__(self, llm_client: LLMClient):
|
||||
"""Initialize Steward mode."""
|
||||
self.llm_client = llm_client
|
||||
self.response_count = 0
|
||||
self.max_responses_per_minute = 2
|
||||
|
||||
async def should_respond(self, message: str, is_mention: bool) -> bool:
|
||||
"""Determine if Steward should respond."""
|
||||
# Only respond to mentions for now (can be expanded)
|
||||
return is_mention and self.response_count < self.max_responses_per_minute
|
||||
|
||||
async def generate_response(
|
||||
self, message: str, context: str | None = None
|
||||
) -> str:
|
||||
"""Generate a thoughtful response to a message."""
|
||||
prompt = PromptTemplates.steward_response(message, context)
|
||||
response = await self.llm_client.generate(prompt, max_tokens=150)
|
||||
self.response_count += 1
|
||||
logger.info("Steward generated response")
|
||||
return response
|
||||
|
||||
async def on_response_sent(self) -> None:
|
||||
"""Record that a response was sent."""
|
||||
logger.debug("Steward response recorded")
|
||||
Reference in New Issue
Block a user