Commit 286d3d80 by Calcium-Ion Committed by GitHub

Merge pull request #2895 from seefs001/fix/model-manager

fix: 如果模型管理有自定义配置则不合并默认配置
parents aed8c07c ac7b183b
...@@ -196,22 +196,27 @@ func updatePricing() { ...@@ -196,22 +196,27 @@ func updatePricing() {
modelSupportEndpointsStr[ability.Model] = endpoints modelSupportEndpointsStr[ability.Model] = endpoints
} }
// 再补充模型自定义端点 // 再补充模型自定义端点:若配置有效则替换默认端点,不做合并
for modelName, meta := range metaMap { for modelName, meta := range metaMap {
if strings.TrimSpace(meta.Endpoints) == "" { if strings.TrimSpace(meta.Endpoints) == "" {
continue continue
} }
var raw map[string]interface{} var raw map[string]interface{}
if err := json.Unmarshal([]byte(meta.Endpoints), &raw); err == nil { if err := json.Unmarshal([]byte(meta.Endpoints), &raw); err == nil {
endpoints := modelSupportEndpointsStr[modelName] endpoints := make([]string, 0, len(raw))
for k := range raw { for k, v := range raw {
switch v.(type) {
case string, map[string]interface{}:
if !common.StringsContains(endpoints, k) { if !common.StringsContains(endpoints, k) {
endpoints = append(endpoints, k) endpoints = append(endpoints, k)
} }
} }
}
if len(endpoints) > 0 {
modelSupportEndpointsStr[modelName] = endpoints modelSupportEndpointsStr[modelName] = endpoints
} }
} }
}
modelSupportEndpointTypes = make(map[string][]constant.EndpointType) modelSupportEndpointTypes = make(map[string][]constant.EndpointType)
for model, endpoints := range modelSupportEndpointsStr { for model, endpoints := range modelSupportEndpointsStr {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment