Sfoglia il codice sorgente

fix: test model #1993

Seefs 4 mesi fa
parent
commit
0fed791ad9
1 ha cambiato i file con 15 aggiunte e 12 eliminazioni
  1. 15 12
      controller/channel-test.go

+ 15 - 12
controller/channel-test.go

@@ -59,6 +59,21 @@ func testChannel(channel *model.Channel, testModel string, endpointType string)
 	w := httptest.NewRecorder()
 	c, _ := gin.CreateTestContext(w)
 
+	testModel = strings.TrimSpace(testModel)
+	if testModel == "" {
+		if channel.TestModel != nil && *channel.TestModel != "" {
+			testModel = strings.TrimSpace(*channel.TestModel)
+		} else {
+			models := channel.GetModels()
+			if len(models) > 0 {
+				testModel = strings.TrimSpace(models[0])
+			}
+			if testModel == "" {
+				testModel = "gpt-4o-mini"
+			}
+		}
+	}
+
 	requestPath := "/v1/chat/completions"
 
 	// 如果指定了端点类型,使用指定的端点类型
@@ -90,18 +105,6 @@ func testChannel(channel *model.Channel, testModel string, endpointType string)
 		Header: make(http.Header),
 	}
 
-	if testModel == "" {
-		if channel.TestModel != nil && *channel.TestModel != "" {
-			testModel = *channel.TestModel
-		} else {
-			if len(channel.GetModels()) > 0 {
-				testModel = channel.GetModels()[0]
-			} else {
-				testModel = "gpt-4o-mini"
-			}
-		}
-	}
-
 	cache, err := model.GetUserCache(1)
 	if err != nil {
 		return testResult{