feat: 增加内容生成配置管理

This commit is contained in:
2026-08-03 17:23:42 +08:00
parent 3f8ff30bbc
commit 8ee4d65b7b
17 changed files with 1348 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
from app.models.admin import Admin, Role
from app.models.ai_config import ModelConfig, Prompt, SystemConfig
from app.models.ai_config import ContentGenerationConfig, ModelConfig, Prompt, SystemConfig
from app.models.base import Base
from app.models.chat import ChatMessage, ChatSession, TopicSession
from app.models.entitlement import EntitlementPlan, UserEntitlement, UserEntitlementLog
@@ -31,6 +31,7 @@ __all__ = [
"Base",
"ChatMessage",
"ChatSession",
"ContentGenerationConfig",
"EntitlementPlan",
"GrowthProfileRevision",
"Knowledge",

View File

@@ -23,6 +23,24 @@ class Prompt(Base):
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
class ContentGenerationConfig(Base):
__tablename__ = "sys_content_generation_config"
__table_args__ = (
Index("ix_content_generation_type_updated", "config_type", "updated_at", "id"),
)
id: Mapped[int] = mapped_column(
BigInteger().with_variant(Integer, "sqlite"), primary_key=True, autoincrement=True
)
config_type: Mapped[str] = mapped_column(String(30), nullable=False)
template_content: Mapped[str] = mapped_column(Text, nullable=False)
instruction_content: Mapped[str] = mapped_column(Text, nullable=False)
change_type: Mapped[str] = mapped_column(String(20), default="save", nullable=False)
source_config_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
updated_by: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
class ModelConfig(Base):
__tablename__ = "sys_model"