Browse Source

修复渠道测试没有走模型映射

Boo p3psi 1 year ago
parent
commit
95ac7c343b
1 changed files with 14 additions and 0 deletions
  1. 14 0
      controller/channel-test.go

+ 14 - 0
controller/channel-test.go

@@ -64,7 +64,21 @@ func testChannel(channel *model.Channel, testModel string) (err error, openaiErr
 		} else {
 			testModel = adaptor.GetModelList()[0]
 		}
+	} else {
+		modelMapping := *channel.ModelMapping
+		if modelMapping != "" && modelMapping != "{}" {
+			modelMap := make(map[string]string)
+			err := json.Unmarshal([]byte(modelMapping), &modelMap)
+			if err != nil {
+				openaiErr := service.OpenAIErrorWrapperLocal(err, "unmarshal_model_mapping_failed", http.StatusInternalServerError).Error
+				return err, &openaiErr
+			}
+			if modelMap[testModel] != "" {
+				testModel = modelMap[testModel]
+			}
+		}
 	}
+
 	request := buildTestRequest()
 	request.Model = testModel
 	meta.UpstreamModelName = testModel