36 lines
1.8 KiB
Python
36 lines
1.8 KiB
Python
"""ORM model for AI writing research templates (课题研究模板).
|
|
|
|
A research template bundles a set of writing-form presets — article type,
|
|
outline, material source, word count, audience, strict mode and a topic/intent —
|
|
so a user can one-click pre-fill the whole 课题研究 form. Maintained from the
|
|
research-template config page (需求 0616 #5).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
|
|
|
|
class ResearchTemplateRow(Base):
|
|
__tablename__ = "ai_writing_research_templates"
|
|
|
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
# 预设字段(点击模板时回填表单)。
|
|
article_type_key: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
outline: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
material_source: Mapped[str] = mapped_column(String(32), nullable=False, default="general")
|
|
word_count: Mapped[int] = mapped_column(Integer, nullable=False, default=800)
|
|
audience: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
|
strict_mode: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
|
topic: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(UTC))
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(UTC))
|