diff --git a/controller/channel-test.go b/controller/channel-test.go index a9f03c45..b8c41819 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -5,6 +5,15 @@ import ( "encoding/json" "errors" "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "strconv" + "strings" + "sync" + "time" + "github.com/songquanpeng/one-api/common/config" "github.com/songquanpeng/one-api/common/ctxkey" "github.com/songquanpeng/one-api/common/logger" @@ -18,14 +27,6 @@ import ( "github.com/songquanpeng/one-api/relay/meta" relaymodel "github.com/songquanpeng/one-api/relay/model" "github.com/songquanpeng/one-api/relay/relaymode" - "io" - "net/http" - "net/http/httptest" - "net/url" - "strconv" - "strings" - "sync" - "time" "github.com/gin-gonic/gin" ) @@ -69,6 +70,7 @@ func testChannel(channel *model.Channel) (err error, openaiErr *relaymodel.Error adaptor.Init(meta) var modelName string modelList := adaptor.GetModelList() + modelMap := channel.GetModelMapping() if len(modelList) != 0 { modelName = modelList[0] } @@ -77,6 +79,9 @@ func testChannel(channel *model.Channel) (err error, openaiErr *relaymodel.Error if len(modelNames) > 0 { modelName = modelNames[0] } + if modelMap != nil && modelMap[modelName] != "" { + modelName = modelMap[modelName] + } } request := buildTestRequest() request.Model = modelName