init
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from models.template import Template
|
||||
from models.paragraph import Paragraph
|
||||
from models.ai_model import AiModel
|
||||
from models.document import Document
|
||||
from models.generation_log import GenerationLog
|
||||
@@ -0,0 +1,14 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, func
|
||||
from database import Base
|
||||
|
||||
class AiModel(Base):
|
||||
__tablename__ = "ai_models"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(255), nullable=False, comment="模型名称")
|
||||
provider = Column(String(100), default="", comment="供应厂商")
|
||||
api_format = Column(String(20), default="openai", comment="anthropic/openai")
|
||||
api_endpoint = Column(String(500), default="", comment="API接口地址")
|
||||
api_key_encrypted = Column(Text, default="", comment="加密后的API Key")
|
||||
status = Column(String(20), default="enabled", comment="enabled/disabled")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
@@ -0,0 +1,15 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, func
|
||||
from database import Base
|
||||
|
||||
class Document(Base):
|
||||
__tablename__ = "documents"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
template_id = Column(Integer, ForeignKey("templates.id"), nullable=False)
|
||||
name = Column(String(255), default="", comment="文档名称")
|
||||
para_count_done = Column(Integer, default=0, comment="已完成段落数")
|
||||
para_count_total = Column(Integer, default=0, comment="总段落数")
|
||||
status = Column(String(20), default="pending", comment="pending/generating/completed/failed/cancelled")
|
||||
file_path = Column(String(500), default="", comment="生成的文件路径")
|
||||
error = Column(Text, default="", comment="错误信息")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
@@ -0,0 +1,14 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, Float, ForeignKey, func
|
||||
from database import Base
|
||||
|
||||
class GenerationLog(Base):
|
||||
__tablename__ = "generation_logs"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
document_id = Column(Integer, ForeignKey("documents.id"), nullable=False)
|
||||
paragraph_id = Column(Integer, ForeignKey("paragraphs.id"), nullable=False)
|
||||
model_id = Column(Integer, ForeignKey("ai_models.id"), nullable=True)
|
||||
status = Column(String(20), default="pending", comment="pending/generating/success/failed")
|
||||
content = Column(Text, default="", comment="生成的内容")
|
||||
duration = Column(Float, default=0, comment="耗时秒数")
|
||||
error_msg = Column(Text, default="", comment="错误信息")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
@@ -0,0 +1,22 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, ForeignKey, func
|
||||
from database import Base
|
||||
|
||||
class Paragraph(Base):
|
||||
__tablename__ = "paragraphs"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
template_id = Column(Integer, ForeignKey("templates.id"), nullable=False)
|
||||
sort_index = Column(Integer, default=0, comment="排序")
|
||||
title = Column(String(500), default="", comment="段落标题")
|
||||
content = Column(Text, default="", comment="正文内容/上下文")
|
||||
style_json = Column(Text, default="{}", comment="段落样式定义JSON")
|
||||
is_table = Column(Boolean, default=False, comment="是否为表格")
|
||||
table_json = Column(Text, default="{}", comment="表格结构JSON")
|
||||
edit_mode = Column(String(20), default="ai", comment="manual/ai")
|
||||
model_id = Column(Integer, ForeignKey("ai_models.id"), nullable=True, comment="指定模型")
|
||||
need_prompt = Column(Boolean, default=True, comment="是否需要提示词")
|
||||
prompt_text = Column(Text, default="", comment="预设提示词")
|
||||
need_file = Column(Boolean, default=False, comment="是否需要上传参考文件")
|
||||
file_note = Column(Text, default="", comment="备注说明(传什么文件)")
|
||||
output_format = Column(String(20), default="text", comment="text/table/mixed/chart")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
@@ -0,0 +1,13 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, func
|
||||
from database import Base
|
||||
|
||||
class Template(Base):
|
||||
__tablename__ = "templates"
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(255), nullable=False, comment="模板名称")
|
||||
description = Column(Text, default="", comment="描述")
|
||||
file_path = Column(String(500), nullable=False, comment="原始模板文件路径")
|
||||
paragraph_count = Column(Integer, default=0, comment="段落数")
|
||||
status = Column(String(20), default="draft", comment="draft/ready")
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
||||
Reference in New Issue
Block a user