增加供应商智能添加功能
This commit is contained in:
@@ -56,6 +56,7 @@ type aiProviderPayload struct {
|
||||
ApiBase string `json:"api_base"`
|
||||
ApiKey string `json:"api_key"`
|
||||
Models []string `json:"models"`
|
||||
DefaultModel string `json:"default_model"` // 默认使用的模型
|
||||
IsDefault int8 `json:"is_default"`
|
||||
Status int8 `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
@@ -108,11 +109,8 @@ func (c *BackendAiProviderController) List() {
|
||||
return
|
||||
}
|
||||
|
||||
// 脱敏api_key + 解析模型列表
|
||||
// 解析模型列表(不脱敏api_key,前端需要完整api_key进行测试)
|
||||
for i := range list {
|
||||
if list[i].ApiKey != "" && len(list[i].ApiKey) > 8 {
|
||||
list[i].ApiKey = list[i].ApiKey[:4] + "****" + list[i].ApiKey[len(list[i].ApiKey)-4:]
|
||||
}
|
||||
list[i].ModelsList = parseProviderModels(list[i].Models)
|
||||
}
|
||||
|
||||
@@ -171,6 +169,7 @@ func (c *BackendAiProviderController) Create() {
|
||||
ApiBase: strings.TrimSpace(p.ApiBase),
|
||||
ApiKey: strings.TrimSpace(p.ApiKey),
|
||||
Models: string(modelsJSON),
|
||||
DefaultModel: strings.TrimSpace(p.DefaultModel),
|
||||
IsDefault: p.IsDefault,
|
||||
Status: p.Status,
|
||||
Remark: strings.TrimSpace(p.Remark),
|
||||
@@ -240,6 +239,7 @@ func (c *BackendAiProviderController) Update() {
|
||||
modelsJSON, _ := json.Marshal(p.Models)
|
||||
provider.Models = string(modelsJSON)
|
||||
}
|
||||
provider.DefaultModel = strings.TrimSpace(p.DefaultModel)
|
||||
provider.IsDefault = p.IsDefault
|
||||
provider.Status = p.Status
|
||||
provider.Remark = strings.TrimSpace(p.Remark)
|
||||
|
||||
Reference in New Issue
Block a user