feat(admin): 重构系统设置页面并新增渠道管理功能
- 将系统设置页面改为公开/私有双标签页结构 - 新增渠道协议、权重配置和加权随机选择算法 - 替换自定义模型为自定义渠道配置选项 - 实现渠道模型远程获取和在线测试功能 - 添加批量测试和抽屉式编辑界面 - 更新文档说明和数据表结构定义
This commit is contained in:
+37
-13
@@ -11,23 +11,24 @@ const (
|
||||
|
||||
// ModelChannel 模型渠道配置。
|
||||
type ModelChannel struct {
|
||||
Key string `json:"key"`
|
||||
Name string `json:"name"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
APIKey string `json:"apiKey"`
|
||||
Models []string `json:"models"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Remark string `json:"remark"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// PublicSetting 公开配置。
|
||||
type PublicSetting struct {
|
||||
AvailableModels []string `json:"availableModels"`
|
||||
DefaultModel string `json:"defaultModel"`
|
||||
DefaultImageModel string `json:"defaultImageModel"`
|
||||
DefaultTextModel string `json:"defaultTextModel"`
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
AllowCustomModel bool `json:"allowCustomModel"`
|
||||
AvailableModels []string `json:"availableModels"`
|
||||
DefaultModel string `json:"defaultModel"`
|
||||
DefaultImageModel string `json:"defaultImageModel"`
|
||||
DefaultTextModel string `json:"defaultTextModel"`
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
AllowCustomChannel bool `json:"allowCustomChannel"`
|
||||
}
|
||||
|
||||
// PrivateSetting 私有配置。
|
||||
@@ -48,3 +49,26 @@ type Settings struct {
|
||||
Public PublicSetting `json:"public"`
|
||||
Private PrivateSetting `json:"private"`
|
||||
}
|
||||
|
||||
func (setting *PublicSetting) UnmarshalJSON(data []byte) error {
|
||||
type alias 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"`
|
||||
AllowCustomModel bool `json:"allowCustomModel"`
|
||||
}
|
||||
var value alias
|
||||
if err := json.Unmarshal(data, &value); err != nil {
|
||||
return err
|
||||
}
|
||||
setting.AvailableModels = value.AvailableModels
|
||||
setting.DefaultModel = value.DefaultModel
|
||||
setting.DefaultImageModel = value.DefaultImageModel
|
||||
setting.DefaultTextModel = value.DefaultTextModel
|
||||
setting.SystemPrompt = value.SystemPrompt
|
||||
setting.AllowCustomChannel = value.AllowCustomChannel || value.AllowCustomModel
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user