release: v2.1.0 - Prompt管理系统、页脚优化、图标修复
This commit is contained in:
32
models.py
32
models.py
@@ -136,3 +136,35 @@ class Admin(UserMixin, db.Model):
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Admin {self.username}>'
|
||||
|
||||
class PromptTemplate(db.Model):
|
||||
"""AI提示词模板模型"""
|
||||
__tablename__ = 'prompt_templates'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
key = db.Column(db.String(50), unique=True, nullable=False, comment='唯一标识(tags/features/description)')
|
||||
name = db.Column(db.String(100), nullable=False, comment='模板名称')
|
||||
system_prompt = db.Column(db.Text, nullable=False, comment='系统提示词')
|
||||
user_prompt_template = db.Column(db.Text, nullable=False, comment='用户提示词模板(支持变量)')
|
||||
description = db.Column(db.String(200), comment='模板说明')
|
||||
is_active = db.Column(db.Boolean, default=True, comment='是否启用')
|
||||
created_at = db.Column(db.DateTime, default=datetime.now, comment='创建时间')
|
||||
updated_at = db.Column(db.DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||||
|
||||
def __repr__(self):
|
||||
return f'<PromptTemplate {self.name}>'
|
||||
|
||||
def to_dict(self):
|
||||
"""转换为字典"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'key': self.key,
|
||||
'name': self.name,
|
||||
'system_prompt': self.system_prompt,
|
||||
'user_prompt_template': self.user_prompt_template,
|
||||
'description': self.description,
|
||||
'is_active': self.is_active,
|
||||
'created_at': self.created_at.strftime('%Y-%m-%d %H:%M:%S') if self.created_at else None,
|
||||
'updated_at': self.updated_at.strftime('%Y-%m-%d %H:%M:%S') if self.updated_at else None
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user