Skip to content

Commit 286d3d8

Browse files
authored
Merge pull request #2895 from seefs001/fix/model-manager
fix: 如果模型管理有自定义配置则不合并默认配置
2 parents aed8c07 + ac7b183 commit 286d3d8

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

model/pricing.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,25 @@ func updatePricing() {
196196
modelSupportEndpointsStr[ability.Model] = endpoints
197197
}
198198

199-
// 再补充模型自定义端点
199+
// 再补充模型自定义端点:若配置有效则替换默认端点,不做合并
200200
for modelName, meta := range metaMap {
201201
if strings.TrimSpace(meta.Endpoints) == "" {
202202
continue
203203
}
204204
var raw map[string]interface{}
205205
if err := json.Unmarshal([]byte(meta.Endpoints), &raw); err == nil {
206-
endpoints := modelSupportEndpointsStr[modelName]
207-
for k := range raw {
208-
if !common.StringsContains(endpoints, k) {
209-
endpoints = append(endpoints, k)
206+
endpoints := make([]string, 0, len(raw))
207+
for k, v := range raw {
208+
switch v.(type) {
209+
case string, map[string]interface{}:
210+
if !common.StringsContains(endpoints, k) {
211+
endpoints = append(endpoints, k)
212+
}
210213
}
211214
}
212-
modelSupportEndpointsStr[modelName] = endpoints
215+
if len(endpoints) > 0 {
216+
modelSupportEndpointsStr[modelName] = endpoints
217+
}
213218
}
214219
}
215220

0 commit comments

Comments
 (0)