MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / testChannel

Function testChannel

controller/channel-test.go:40–283  ·  view source on GitHub ↗
(channel *model.Channel, testModel string)

Source from the content-addressed store, hash-verified

38}
39
40func testChannel(channel *model.Channel, testModel string) testResult {
41 tik := time.Now()
42 if channel.Type == constant.ChannelTypeMidjourney {
43 return testResult{
44 localErr: errors.New("midjourney channel test is not supported"),
45 newAPIError: nil,
46 }
47 }
48 if channel.Type == constant.ChannelTypeMidjourneyPlus {
49 return testResult{
50 localErr: errors.New("midjourney plus channel test is not supported"),
51 newAPIError: nil,
52 }
53 }
54 if channel.Type == constant.ChannelTypeSunoAPI {
55 return testResult{
56 localErr: errors.New("suno channel test is not supported"),
57 newAPIError: nil,
58 }
59 }
60 if channel.Type == constant.ChannelTypeKling {
61 return testResult{
62 localErr: errors.New("kling channel test is not supported"),
63 newAPIError: nil,
64 }
65 }
66 if channel.Type == constant.ChannelTypeJimeng {
67 return testResult{
68 localErr: errors.New("jimeng channel test is not supported"),
69 newAPIError: nil,
70 }
71 }
72 w := httptest.NewRecorder()
73 c, _ := gin.CreateTestContext(w)
74
75 requestPath := "/v1/chat/completions"
76
77 // 先判断是否为 Embedding 模型
78 if strings.Contains(strings.ToLower(testModel), "embedding") ||
79 strings.HasPrefix(testModel, "m3e") || // m3e 系列模型
80 strings.Contains(testModel, "bge-") || // bge 系列模型
81 strings.Contains(testModel, "embed") ||
82 channel.Type == constant.ChannelTypeMokaAI { // 其他 embedding 模型
83 requestPath = "/v1/embeddings" // 修改请求路径
84 }
85
86 c.Request = &http.Request{
87 Method: "POST",
88 URL: &url.URL{Path: requestPath}, // 使用动态路径
89 Body: nil,
90 Header: make(http.Header),
91 }
92
93 if testModel == "" {
94 if channel.TestModel != nil && *channel.TestModel != "" {
95 testModel = *channel.TestModel
96 } else {
97 if len(channel.GetModels()) > 0 {

Callers 3

TestChannelFunction · 0.85
testAllChannelsFunction · 0.85
ChannelsTable.jsFile · 0.85

Calls 15

GetUserCacheFunction · 0.92
GetUserGroupFunction · 0.92
ModelMappedHelperFunction · 0.92
NewErrorFunction · 0.92
GetAdaptorFunction · 0.92
ModelPriceHelperFunction · 0.92
RelayErrorHandlerFunction · 0.92
GenerateTextOtherInfoFunction · 0.92
RecordConsumeLogFunction · 0.92
buildTestRequestFunction · 0.85
ContainsMethod · 0.80

Tested by 1

TestChannelFunction · 0.68