Browse Source

fix: fix the shared field is modified

JustSong 2 years ago
parent
commit
1cb1f727c0
1 changed files with 7 additions and 7 deletions
  1. 7 7
      controller/channel-test.go

+ 7 - 7
controller/channel-test.go

@@ -14,12 +14,12 @@ import (
 	"time"
 )
 
-func testChannel(channel *model.Channel, request *ChatRequest) error {
-	if request.Model == "" {
+func testChannel(channel *model.Channel, request ChatRequest) error {
+	switch channel.Type {
+	case common.ChannelTypeAzure:
+		request.Model = "gpt-35-turbo"
+	default:
 		request.Model = "gpt-3.5-turbo"
-		if channel.Type == common.ChannelTypeAzure {
-			request.Model = "gpt-35-turbo"
-		}
 	}
 	requestURL := common.ChannelBaseURLs[channel.Type]
 	if channel.Type == common.ChannelTypeAzure {
@@ -97,7 +97,7 @@ func TestChannel(c *gin.Context) {
 	}
 	testRequest := buildTestRequest(c)
 	tik := time.Now()
-	err = testChannel(channel, testRequest)
+	err = testChannel(channel, *testRequest)
 	tok := time.Now()
 	milliseconds := tok.Sub(tik).Milliseconds()
 	go channel.UpdateResponseTime(milliseconds)
@@ -165,7 +165,7 @@ func testAllChannels(c *gin.Context) error {
 				continue
 			}
 			tik := time.Now()
-			err := testChannel(channel, testRequest)
+			err := testChannel(channel, *testRequest)
 			tok := time.Now()
 			milliseconds := tok.Sub(tik).Milliseconds()
 			if err != nil || milliseconds > disableThreshold {