refactor: 大模型配置改为列表选择模式

- 移除主配置表单,改为从列表选择默认接口
- 新增 is_default 字段标记默认使用的接口
- 新增 max_tokens/chunk_size/timeout 配置参数
- 点击"设为默认"按钮即可切换当前使用的接口
- get_llm_config() 从默认接口获取配置
- 默认接口不可删除,必须有至少一个默认
This commit is contained in:
2026-04-16 16:21:15 +08:00
parent db98c2b82c
commit 07cd82e192
3 changed files with 236 additions and 197 deletions

View File

@@ -871,7 +871,7 @@ class EmailNotification(db.Model):
# ==================== 备用大模型接口配置 ====================
class BackupLLMConfig(db.Model):
"""备用大模型接口配置"""
"""大模型接口配置"""
__tablename__ = 'backup_llm_config'
id = db.Column(db.Integer, primary_key=True)
@@ -882,8 +882,14 @@ class BackupLLMConfig(db.Model):
api_key = db.Column(db.String(255), nullable=True) # API Key可选
model = db.Column(db.String(100), nullable=True) # 默认模型
# 配置参数
max_tokens = db.Column(db.Integer, default=8000) # 最大输出Token
chunk_size = db.Column(db.Integer, default=2000) # 分块大小
timeout = db.Column(db.Integer, default=180) # 超时时间
# 状态
is_active = db.Column(db.Boolean, default=True) # 是否启用
is_default = db.Column(db.Boolean, default=False) # 是否默认使用
sort_order = db.Column(db.Integer, default=0) # 排序
# 备注
@@ -900,7 +906,11 @@ class BackupLLMConfig(db.Model):
'api_base': self.api_base,
'api_key': self.api_key,
'model': self.model,
'max_tokens': self.max_tokens,
'chunk_size': self.chunk_size,
'timeout': self.timeout,
'is_active': self.is_active,
'is_default': self.is_default,
'sort_order': self.sort_order,
'description': self.description,
'created_at': self.created_at.isoformat() if self.created_at else None,