afd9631735
- 将公开设置中的模型相关字段统一收拢到 modelChannel 配置组 - 更新 AdminPublicSettings 类型定义为 AdminPublicModelChannelSettings - 在前端表单中调整模型配置字段路径到 public.modelChannel 下 - 更新设置规范化函数以适配新的嵌套配置结构 - 修改依赖注入和文档以反映配置结构变化 - 添加系统配置数据结构文档说明新的配置格式
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package model
|
|
|
|
type SettingKey string
|
|
|
|
const (
|
|
SettingKeyPublic SettingKey = "public"
|
|
SettingKeyPrivate SettingKey = "private"
|
|
)
|
|
|
|
// ModelChannel 模型渠道配置。
|
|
type ModelChannel struct {
|
|
Protocol string `json:"protocol"`
|
|
Name string `json:"name"`
|
|
BaseURL string `json:"baseUrl"`
|
|
APIKey string `json:"apiKey"`
|
|
Models []string `json:"models"`
|
|
Weight int `json:"weight"`
|
|
Enabled bool `json:"enabled"`
|
|
Remark string `json:"remark"`
|
|
}
|
|
|
|
// PublicModelChannelSetting 公开模型渠道配置。
|
|
type PublicModelChannelSetting struct {
|
|
AvailableModels []string `json:"availableModels"`
|
|
DefaultModel string `json:"defaultModel"`
|
|
DefaultImageModel string `json:"defaultImageModel"`
|
|
DefaultTextModel string `json:"defaultTextModel"`
|
|
SystemPrompt string `json:"systemPrompt"`
|
|
AllowCustomChannel bool `json:"allowCustomChannel"`
|
|
}
|
|
|
|
// PublicSetting 公开配置。
|
|
type PublicSetting struct {
|
|
ModelChannel PublicModelChannelSetting `json:"modelChannel"`
|
|
}
|
|
|
|
// PrivateSetting 私有配置。
|
|
type PrivateSetting struct {
|
|
Channels []ModelChannel `json:"channels"`
|
|
}
|
|
|
|
// Setting 系统配置。
|
|
type Setting struct {
|
|
Key SettingKey `json:"key" gorm:"primaryKey"`
|
|
Value json.RawMessage `json:"value" gorm:"serializer:json"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
}
|
|
|
|
// Settings 系统公开和私有配置。
|
|
type Settings struct {
|
|
Public PublicSetting `json:"public"`
|
|
Private PrivateSetting `json:"private"`
|
|
}
|