forked from hesabix/arc
48 lines
1.7 KiB
Python
Executable file
48 lines
1.7 KiB
Python
Executable file
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from sqlalchemy import String, Integer, DateTime, ForeignKey, Text, Boolean, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from adapters.db.session import Base
|
|
import enum
|
|
|
|
|
|
class PromptRole(str, enum.Enum):
|
|
OPERATOR = "operator"
|
|
USER = "user"
|
|
ADMIN = "admin"
|
|
|
|
|
|
class PromptType(str, enum.Enum):
|
|
SYSTEM = "system"
|
|
USER = "user"
|
|
|
|
|
|
class AIPrompt(Base):
|
|
__tablename__ = "ai_prompts"
|
|
__table_args__ = (
|
|
UniqueConstraint("prompt_key", name="uq_ai_prompts_prompt_key"),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
|
|
prompt_key: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
|
|
role: Mapped[str] = mapped_column(String(50), nullable=False, index=True)
|
|
prompt_type: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
category: Mapped[str] = mapped_column(String(50), nullable=False, default="chat", index=True)
|
|
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
|
|
user_id: Mapped[int | None] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=True, index=True
|
|
)
|
|
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
|
)
|
|
|
|
user = relationship("User", backref="ai_prompts")
|