MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / getChannel

Function getChannel

controller/relay.go:248–274  ·  view source on GitHub ↗
(c *gin.Context, group, originalModel string, retryCount int)

Source from the content-addressed store, hash-verified

246}
247
248func getChannel(c *gin.Context, group, originalModel string, retryCount int) (*model.Channel, *types.NewAPIError) {
249 if retryCount == 0 {
250 autoBan := c.GetBool("auto_ban")
251 autoBanInt := 1
252 if !autoBan {
253 autoBanInt = 0
254 }
255 return &model.Channel{
256 Id: c.GetInt("channel_id"),
257 Type: c.GetInt("channel_type"),
258 Name: c.GetString("channel_name"),
259 AutoBan: &autoBanInt,
260 }, nil
261 }
262 channel, selectGroup, err := model.CacheGetRandomSatisfiedChannel(c, group, originalModel, retryCount)
263 if err != nil {
264 if group == "auto" {
265 return nil, types.NewError(errors.New(fmt.Sprintf("获取自动分组下模型 %s 的可用渠道失败: %s", originalModel, err.Error())), types.ErrorCodeGetChannelFailed)
266 }
267 return nil, types.NewError(errors.New(fmt.Sprintf("获取分组 %s 下模型 %s 的可用渠道失败: %s", selectGroup, originalModel, err.Error())), types.ErrorCodeGetChannelFailed)
268 }
269 newAPIError := middleware.SetupContextForSelectedChannel(c, channel, originalModel)
270 if newAPIError != nil {
271 return nil, newAPIError
272 }
273 return channel, nil
274}
275
276func shouldRetry(c *gin.Context, openaiErr *types.NewAPIError, retryTimes int) bool {
277 if openaiErr == nil {

Callers 5

PlaygroundFunction · 0.85
RelayFunction · 0.85
WssRelayFunction · 0.85
RelayClaudeFunction · 0.85
RelayTaskFunction · 0.85

Calls 4

NewErrorFunction · 0.92
ErrorMethod · 0.80

Tested by

no test coverage detected