feat: 备用大模型接口管理功能

- 新增 BackupLLMConfig 数据模型存储备用大模型配置
- 支持手动新增、编辑、删除备用大模型接口
- 支持测试连接功能
- 大模型配置页面静态表格改为动态管理的备用接口链接
- 默认初始化5个常用大模型服务商配置
This commit is contained in:
2026-04-16 14:36:13 +08:00
parent 9a36b9245a
commit 8ef9df65d2
5 changed files with 613 additions and 15 deletions

View File

@@ -869,6 +869,44 @@ class EmailNotification(db.Model):
}
# ==================== 备用大模型接口配置 ====================
class BackupLLMConfig(db.Model):
"""备用大模型接口配置"""
__tablename__ = 'backup_llm_config'
id = db.Column(db.Integer, primary_key=True)
# 服务商信息
provider_name = db.Column(db.String(100), nullable=False) # 服务商名称: OpenAI, DeepSeek, 阿里百炼, etc.
api_base = db.Column(db.String(255), nullable=False) # API地址
api_key = db.Column(db.String(255), nullable=True) # API Key可选
model = db.Column(db.String(100), nullable=True) # 默认模型
# 状态
is_active = db.Column(db.Boolean, default=True) # 是否启用
sort_order = db.Column(db.Integer, default=0) # 排序
# 备注
description = db.Column(db.String(255), nullable=True) # 备注
# 时间
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
def to_dict(self):
return {
'id': self.id,
'provider_name': self.provider_name,
'api_base': self.api_base,
'api_key': self.api_key,
'model': self.model,
'is_active': self.is_active,
'sort_order': self.sort_order,
'description': self.description,
'created_at': self.created_at.isoformat() if self.created_at else None,
}
# ==================== 邮件模板配置 ====================
class EmailTemplateConfig(db.Model):
"""邮件模板配置"""