Files
ws-sanctum-chronicler/app/llm/prompts.py

87 lines
3.4 KiB
Python

"""LLM prompt templates and generation utilities."""
from typing import Optional
class PromptTemplates:
"""Collection of prompt templates for different modes."""
@staticmethod
def gentle_prompt(
current_theme: Optional[str] = None,
dashboard: Optional[dict] = None,
recent_discussion: Optional[list[str]] = None,
) -> str:
"""Generate a gentle prompt when chat has been inactive."""
dashboard = dashboard or {}
recent_discussion = recent_discussion or []
context_lines = [
"Generate one brief Hearthkeeper prompt for a calm, reflective livestream.",
"The prompt must be restrained, thematic, and not engagement bait.",
]
if dashboard.get("stream_title"):
context_lines.append(f"Stream title: {dashboard['stream_title']}")
if dashboard.get("game"):
context_lines.append(f"Game: {dashboard['game']}")
if dashboard.get("mood"):
context_lines.append(f"Mood: {dashboard['mood']}")
if dashboard.get("content_angle"):
context_lines.append(f"Content angle: {dashboard['content_angle']}")
if dashboard.get("session_goals"):
goals = "; ".join(dashboard["session_goals"])
context_lines.append(f"Session goals: {goals}")
if current_theme:
context_lines.append(f"Current theme: {current_theme}")
if recent_discussion:
context_lines.append("Recent human discussion:")
context_lines.extend(f"- {message}" for message in recent_discussion[:5])
return "\n".join(context_lines)
@staticmethod
def steward_response(message: str, context: Optional[str] = None) -> str:
"""Generate a response as the Steward mode."""
prompt = f"As a thoughtful steward of this stream, respond briefly and helpfully to: {message}"
if context:
prompt += f"\nContext: {context}"
return prompt
@staticmethod
def warden_analysis(message: str) -> str:
"""Generate analysis for suspicious content detection."""
return f"Analyze this message for suspicious patterns (spam, scams, manipulation): {message}"
@staticmethod
def librarian_summary(messages: list[str]) -> str:
"""Generate a summary of important discussion points."""
messages_text = "\n".join(messages)
return f"Summarize the key discussion points from this chat log:\n{messages_text}"
@staticmethod
def scribe_ledger(
theme: str,
discussion: list[str],
actions: list[str],
clips: list[str],
seeds: list[str],
) -> str:
"""Generate markdown ledger summary."""
return f"""Generate a professional markdown ledger with these sections:
- Theme: {theme}
- Notable Discussion: {len(discussion)} key points
- Agent Actions: {len(actions)} recorded
- Clip Candidates: {len(clips)} identified
- Blog Seeds: {len(seeds)} proposed"""
@staticmethod
def clip_candidate_reason(message: str) -> str:
"""Generate reasoning for marking a message as a clip candidate."""
return f"Explain why this is a good clip candidate: {message}"
@staticmethod
def blog_seed_topic(context: list[str]) -> str:
"""Generate a blog post topic from discussion context."""
context_text = "\n".join(context[:5]) # First 5 messages
return f"Based on this discussion, suggest a blog post topic:\n{context_text}"