Merge pull request #1963 from feitianbubu/pr/refactor-channel-test
refactor: simplify unsupported test channel types
This commit is contained in:
commit
c3e28946a4
@ -113,3 +113,64 @@ var ChannelBaseURLs = []string{
|
|||||||
"https://llm.submodel.ai", //53
|
"https://llm.submodel.ai", //53
|
||||||
"https://ark.cn-beijing.volces.com", //54
|
"https://ark.cn-beijing.volces.com", //54
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ChannelTypeNames = map[int]string{
|
||||||
|
ChannelTypeUnknown: "Unknown",
|
||||||
|
ChannelTypeOpenAI: "OpenAI",
|
||||||
|
ChannelTypeMidjourney: "Midjourney",
|
||||||
|
ChannelTypeAzure: "Azure",
|
||||||
|
ChannelTypeOllama: "Ollama",
|
||||||
|
ChannelTypeMidjourneyPlus: "MidjourneyPlus",
|
||||||
|
ChannelTypeOpenAIMax: "OpenAIMax",
|
||||||
|
ChannelTypeOhMyGPT: "OhMyGPT",
|
||||||
|
ChannelTypeCustom: "Custom",
|
||||||
|
ChannelTypeAILS: "AILS",
|
||||||
|
ChannelTypeAIProxy: "AIProxy",
|
||||||
|
ChannelTypePaLM: "PaLM",
|
||||||
|
ChannelTypeAPI2GPT: "API2GPT",
|
||||||
|
ChannelTypeAIGC2D: "AIGC2D",
|
||||||
|
ChannelTypeAnthropic: "Anthropic",
|
||||||
|
ChannelTypeBaidu: "Baidu",
|
||||||
|
ChannelTypeZhipu: "Zhipu",
|
||||||
|
ChannelTypeAli: "Ali",
|
||||||
|
ChannelTypeXunfei: "Xunfei",
|
||||||
|
ChannelType360: "360",
|
||||||
|
ChannelTypeOpenRouter: "OpenRouter",
|
||||||
|
ChannelTypeAIProxyLibrary: "AIProxyLibrary",
|
||||||
|
ChannelTypeFastGPT: "FastGPT",
|
||||||
|
ChannelTypeTencent: "Tencent",
|
||||||
|
ChannelTypeGemini: "Gemini",
|
||||||
|
ChannelTypeMoonshot: "Moonshot",
|
||||||
|
ChannelTypeZhipu_v4: "ZhipuV4",
|
||||||
|
ChannelTypePerplexity: "Perplexity",
|
||||||
|
ChannelTypeLingYiWanWu: "LingYiWanWu",
|
||||||
|
ChannelTypeAws: "AWS",
|
||||||
|
ChannelTypeCohere: "Cohere",
|
||||||
|
ChannelTypeMiniMax: "MiniMax",
|
||||||
|
ChannelTypeSunoAPI: "SunoAPI",
|
||||||
|
ChannelTypeDify: "Dify",
|
||||||
|
ChannelTypeJina: "Jina",
|
||||||
|
ChannelCloudflare: "Cloudflare",
|
||||||
|
ChannelTypeSiliconFlow: "SiliconFlow",
|
||||||
|
ChannelTypeVertexAi: "VertexAI",
|
||||||
|
ChannelTypeMistral: "Mistral",
|
||||||
|
ChannelTypeDeepSeek: "DeepSeek",
|
||||||
|
ChannelTypeMokaAI: "MokaAI",
|
||||||
|
ChannelTypeVolcEngine: "VolcEngine",
|
||||||
|
ChannelTypeBaiduV2: "BaiduV2",
|
||||||
|
ChannelTypeXinference: "Xinference",
|
||||||
|
ChannelTypeXai: "xAI",
|
||||||
|
ChannelTypeCoze: "Coze",
|
||||||
|
ChannelTypeKling: "Kling",
|
||||||
|
ChannelTypeJimeng: "Jimeng",
|
||||||
|
ChannelTypeVidu: "Vidu",
|
||||||
|
ChannelTypeSubmodel: "Submodel",
|
||||||
|
ChannelTypeDoubaoVideo: "DoubaoVideo",
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetChannelTypeName(channelType int) string {
|
||||||
|
if name, ok := ChannelTypeNames[channelType]; ok {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bytedance/gopkg/util/gopool"
|
"github.com/bytedance/gopkg/util/gopool"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -40,46 +41,19 @@ type testResult struct {
|
|||||||
|
|
||||||
func testChannel(channel *model.Channel, testModel string, endpointType string) testResult {
|
func testChannel(channel *model.Channel, testModel string, endpointType string) testResult {
|
||||||
tik := time.Now()
|
tik := time.Now()
|
||||||
if channel.Type == constant.ChannelTypeMidjourney {
|
var unsupportedTestChannelTypes = []int{
|
||||||
return testResult{
|
constant.ChannelTypeMidjourney,
|
||||||
localErr: errors.New("midjourney channel test is not supported"),
|
constant.ChannelTypeMidjourneyPlus,
|
||||||
newAPIError: nil,
|
constant.ChannelTypeSunoAPI,
|
||||||
}
|
constant.ChannelTypeKling,
|
||||||
|
constant.ChannelTypeJimeng,
|
||||||
|
constant.ChannelTypeDoubaoVideo,
|
||||||
|
constant.ChannelTypeVidu,
|
||||||
}
|
}
|
||||||
if channel.Type == constant.ChannelTypeMidjourneyPlus {
|
if lo.Contains(unsupportedTestChannelTypes, channel.Type) {
|
||||||
|
channelTypeName := constant.GetChannelTypeName(channel.Type)
|
||||||
return testResult{
|
return testResult{
|
||||||
localErr: errors.New("midjourney plus channel test is not supported"),
|
localErr: fmt.Errorf("%s channel test is not supported", channelTypeName),
|
||||||
newAPIError: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if channel.Type == constant.ChannelTypeSunoAPI {
|
|
||||||
return testResult{
|
|
||||||
localErr: errors.New("suno channel test is not supported"),
|
|
||||||
newAPIError: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if channel.Type == constant.ChannelTypeKling {
|
|
||||||
return testResult{
|
|
||||||
localErr: errors.New("kling channel test is not supported"),
|
|
||||||
newAPIError: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if channel.Type == constant.ChannelTypeJimeng {
|
|
||||||
return testResult{
|
|
||||||
localErr: errors.New("jimeng channel test is not supported"),
|
|
||||||
newAPIError: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if channel.Type == constant.ChannelTypeDoubaoVideo {
|
|
||||||
return testResult{
|
|
||||||
localErr: errors.New("doubao video channel test is not supported"),
|
|
||||||
newAPIError: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if channel.Type == constant.ChannelTypeVidu {
|
|
||||||
return testResult{
|
|
||||||
localErr: errors.New("vidu channel test is not supported"),
|
|
||||||
newAPIError: nil,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user