Add FastAPI backend with agent system
This commit is contained in:
28
backend/app/models/agent.py
Normal file
28
backend/app/models/agent.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from sqlalchemy import Column, String, Text, Boolean, ForeignKey, Integer
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.models.base import BaseModel
|
||||
|
||||
|
||||
class Agent(BaseModel):
|
||||
__tablename__ = "agents"
|
||||
|
||||
name = Column(String(100), nullable=False)
|
||||
role = Column(String(100), nullable=False) # master, planner, executor, librarian, analyst
|
||||
description = Column(Text, nullable=True)
|
||||
system_prompt = Column(Text, nullable=False)
|
||||
is_active = Column(Boolean, default=True)
|
||||
is_default = Column(Boolean, default=False)
|
||||
|
||||
messages = relationship("AgentMessage", back_populates="agent", cascade="all, delete-orphan")
|
||||
replies = relationship("ForumReply", back_populates="agent")
|
||||
|
||||
|
||||
class AgentMessage(BaseModel):
|
||||
__tablename__ = "agent_messages"
|
||||
|
||||
agent_id = Column(String(36), ForeignKey("agents.id"), nullable=False, index=True)
|
||||
conversation_id = Column(String(36), ForeignKey("conversations.id"), nullable=False, index=True)
|
||||
role = Column(String(20), nullable=False) # system, user, assistant
|
||||
content = Column(Text, nullable=False)
|
||||
|
||||
agent = relationship("Agent", back_populates="messages")
|
||||
Reference in New Issue
Block a user