27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
"""ORM model for per-user custom prompts (常用提示词)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
from deerflow.persistence.types import BeijingDateTime
|
|
|
|
|
|
class UserCustomPromptRow(Base):
|
|
__tablename__ = "user_custom_prompts"
|
|
|
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
user_id: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False, default="")
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
|
# Optional association to a single agent. NULL = global (shown everywhere);
|
|
# otherwise the prompt only surfaces when that agent is selected.
|
|
agent_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
|
created_at: Mapped[datetime] = mapped_column(BeijingDateTime(), nullable=False, default=lambda: datetime.now(UTC))
|
|
updated_at: Mapped[datetime] = mapped_column(BeijingDateTime(), nullable=False, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))
|