From 49cec509080dac0c6443b4151bdf18f56f9ce7e2 Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Mon, 8 Jul 2024 17:06:29 +0800 Subject: [PATCH] fix: channel default test model --- controller/channel-test.go | 4 ++-- model/channel.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index 0113f7ec..e3cef38e 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -67,8 +67,8 @@ func testChannel(channel *model.Channel, testModel string) (err error, openaiErr if channel.TestModel != nil && *channel.TestModel != "" { testModel = *channel.TestModel } else { - if len(adaptor.GetModelList()) > 0 { - testModel = adaptor.GetModelList()[0] + if len(channel.GetModels()) > 0 { + testModel = channel.GetModels()[0] } else { testModel = "gpt-3.5-turbo" } diff --git a/model/channel.go b/model/channel.go index b929cf0d..8603033b 100644 --- a/model/channel.go +++ b/model/channel.go @@ -4,6 +4,7 @@ import ( "encoding/json" "gorm.io/gorm" "one-api/common" + "strings" ) type Channel struct { @@ -33,6 +34,13 @@ type Channel struct { OtherInfo string `json:"other_info"` } +func (channel *Channel) GetModels() []string { + if channel.Models == "" { + return []string{} + } + return strings.Split(strings.Trim(channel.Models, ","), ",") +} + func (channel *Channel) GetOtherInfo() map[string]interface{} { otherInfo := make(map[string]interface{}) if channel.OtherInfo != "" {