From 455269c1452017d1a9cfb10c5f1acdfc4a367ffd Mon Sep 17 00:00:00 2001 From: Martial BE Date: Wed, 29 Nov 2023 16:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B8=A0=E9=81=93=E6=B5=8B=E8=AF=95=E5=87=BD=E6=95=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/channel-test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index a1656470..64556107 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -7,6 +7,8 @@ import ( "net/http/httptest" "one-api/common" "one-api/model" + "one-api/providers" + providers_base "one-api/providers/base" "one-api/types" "strconv" "sync" @@ -58,7 +60,15 @@ func testChannel(channel *model.Channel, request types.ChatCompletionRequest) (e request.Model = "gpt-3.5-turbo" } - chatProvider := GetChatProvider(channel.Type, c) + provider := providers.GetProvider(channel.Type, c) + if provider == nil { + return errors.New("channel not implemented"), nil + } + chatProvider, ok := provider.(providers_base.ChatInterface) + if !ok { + return errors.New("channel not implemented"), nil + } + isModelMapped := false modelMap, err := parseModelMapping(c.GetString("model_mapping")) if err != nil { @@ -180,7 +190,7 @@ func testAllChannels(notify bool) error { tok := time.Now() milliseconds := tok.Sub(tik).Milliseconds() if milliseconds > disableThreshold { - err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0)) + err = fmt.Errorf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0) disableChannel(channel.Id, channel.Name, err.Error()) } if shouldDisableChannel(openaiErr, -1) { @@ -215,7 +225,6 @@ func TestAllChannels(c *gin.Context) { "success": true, "message": "", }) - return } func AutomaticallyTestChannels(frequency int) {