AI generated first iteration
This commit is contained in:
84
app/memory/models.py
Normal file
84
app/memory/models.py
Normal file
@@ -0,0 +1,84 @@
|
||||
"""Memory and database models."""
|
||||
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from sqlalchemy import Column, String, DateTime, Text, Integer, Boolean, Enum as SQLEnum
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class StreamSession(Base):
|
||||
"""Represents a single stream session."""
|
||||
|
||||
__tablename__ = "stream_sessions"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
channel_name = Column(String, nullable=False, index=True)
|
||||
started_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
ended_at = Column(DateTime, nullable=True)
|
||||
theme = Column(Text, nullable=True)
|
||||
is_active = Column(Boolean, default=True)
|
||||
|
||||
|
||||
class ChatMessage(Base):
|
||||
"""Represents a chat message from the stream."""
|
||||
|
||||
__tablename__ = "chat_messages"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
session_id = Column(String, nullable=False, index=True)
|
||||
username = Column(String, nullable=False)
|
||||
content = Column(Text, nullable=False)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
is_bot = Column(Boolean, default=False)
|
||||
is_moderator = Column(Boolean, default=False)
|
||||
|
||||
|
||||
class AgentActionType(str, Enum):
|
||||
"""Types of actions the agent can take."""
|
||||
|
||||
RESPONSE = "response"
|
||||
FLAG_SUSPICIOUS = "flag_suspicious"
|
||||
ARCHIVE_CLIP = "archive_clip"
|
||||
RECORD_SEED = "record_seed"
|
||||
UPDATE_THEME = "update_theme"
|
||||
|
||||
|
||||
class AgentAction(Base):
|
||||
"""Records of agent actions taken during a session."""
|
||||
|
||||
__tablename__ = "agent_actions"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
session_id = Column(String, nullable=False, index=True)
|
||||
action_type = Column(SQLEnum(AgentActionType), nullable=False)
|
||||
mode = Column(String, nullable=False) # hearthkeeper, steward, warden, etc.
|
||||
triggered_by_message_id = Column(String, nullable=True)
|
||||
description = Column(Text, nullable=False)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class ClipCandidate(Base):
|
||||
"""Stores potential clip candidates from stream chat."""
|
||||
|
||||
__tablename__ = "clip_candidates"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
session_id = Column(String, nullable=False, index=True)
|
||||
message_id = Column(String, nullable=False)
|
||||
reason = Column(Text, nullable=False)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class BlogSeed(Base):
|
||||
"""Stores potential blog post topics/seeds from stream."""
|
||||
|
||||
__tablename__ = "blog_seeds"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
session_id = Column(String, nullable=False, index=True)
|
||||
topic = Column(String, nullable=False)
|
||||
description = Column(Text, nullable=False)
|
||||
related_messages = Column(Text, nullable=True) # JSON array of message IDs
|
||||
timestamp = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
Reference in New Issue
Block a user