- 后端新增 featured_order 字段及精选排序 API(/agents/selector、/agents/{id}/featured、/agents/featured/order),移除 user_agent_pin 表
- 前端新对话页 (ChatPage) 与输入框 (InputBox) 接入 agent-selector,选中后跳转 AgentChatPage 并通过 sessionStorage 透传首条消息
- 新增管理员智能体管理弹窗 (agent-manage-dialog) 支持精选添加/移除/上下移动
32 lines
1.6 KiB
Python
32 lines
1.6 KiB
Python
"""ORM model for custom agents."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import BigInteger, Boolean, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
from deerflow.persistence.types import BeijingDateTime
|
|
|
|
|
|
class AgentRow(Base):
|
|
__tablename__ = "agents"
|
|
|
|
# Stored as a plain string so the same id can be used as the filesystem
|
|
# directory name under {base_dir}/agents/{id}/.
|
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(191), nullable=False, index=True)
|
|
description: Mapped[str] = mapped_column(String(1024), nullable=False, default="")
|
|
user_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
|
published: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
|
|
# NULL = not featured on the homepage selector. Non-NULL = admin-curated
|
|
# featured rank (lower sorts first). Only ``published=True`` agents are
|
|
# eligible; the router enforces that invariant on writes. BIGINT so the
|
|
# frontend can seed initial ranks from ``Date.now()`` (ms-resolution
|
|
# timestamps overflow a 4-byte INT on MySQL).
|
|
featured_order: Mapped[int | None] = mapped_column(BigInteger, 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))
|