Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5418bb3b
authored
Jul 23, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: improve error messages for channel retrieval failures in distributor and relay
parent
5bd8dd78
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
8 deletions
+5
-8
controller/relay.go
+3
-3
middleware/distributor.go
+2
-2
model/channel_cache.go
+0
-3
No files found.
controller/relay.go
View file @
5418bb3b
...
...
@@ -259,10 +259,10 @@ func getChannel(c *gin.Context, group, originalModel string, retryCount int) (*m
}
channel
,
selectGroup
,
err
:=
model
.
CacheGetRandomSatisfiedChannel
(
c
,
group
,
originalModel
,
retryCount
)
if
err
!=
nil
{
if
group
==
"auto"
{
return
nil
,
types
.
NewError
(
errors
.
New
(
fmt
.
Sprintf
(
"获取自动分组下模型 %s 的可用渠道失败: %s"
,
originalModel
,
err
.
Error
())),
types
.
ErrorCodeGetChannelFailed
)
return
nil
,
types
.
NewError
(
errors
.
New
(
fmt
.
Sprintf
(
"获取分组 %s 下模型 %s 的可用渠道失败(retry): %s"
,
selectGroup
,
originalModel
,
err
.
Error
())),
types
.
ErrorCodeGetChannelFailed
)
}
return
nil
,
types
.
NewError
(
errors
.
New
(
fmt
.
Sprintf
(
"获取分组 %s 下模型 %s 的可用渠道失败: %s"
,
selectGroup
,
originalModel
,
err
.
Error
())),
types
.
ErrorCodeGetChannelFailed
)
if
channel
==
nil
{
return
nil
,
types
.
NewError
(
errors
.
New
(
fmt
.
Sprintf
(
"分组 %s 下模型 %s 的可用渠道不存在(数据库一致性已被破坏,retry)"
,
selectGroup
,
originalModel
)),
types
.
ErrorCodeGetChannelFailed
)
}
newAPIError
:=
middleware
.
SetupContextForSelectedChannel
(
c
,
channel
,
originalModel
)
if
newAPIError
!=
nil
{
...
...
middleware/distributor.go
View file @
5418bb3b
...
...
@@ -107,7 +107,7 @@ func Distribute() func(c *gin.Context) {
if
userGroup
==
"auto"
{
showGroup
=
fmt
.
Sprintf
(
"auto(%s)"
,
selectGroup
)
}
message
:=
fmt
.
Sprintf
(
"
当前分组 %s 下对于模型 %s 无可用渠道"
,
showGroup
,
modelRequest
.
Model
)
message
:=
fmt
.
Sprintf
(
"
获取分组 %s 下模型 %s 的可用渠道失败(distributor): %s"
,
showGroup
,
modelRequest
.
Model
,
err
.
Error
()
)
// 如果错误,但是渠道不为空,说明是数据库一致性问题
if
channel
!=
nil
{
common
.
SysError
(
fmt
.
Sprintf
(
"渠道不存在:%d"
,
channel
.
Id
))
...
...
@@ -118,7 +118,7 @@ func Distribute() func(c *gin.Context) {
return
}
if
channel
==
nil
{
abortWithOpenAiMessage
(
c
,
http
.
StatusServiceUnavailable
,
fmt
.
Sprintf
(
"
当前分组 %s 下对于模型 %s 无可用渠道(数据库一致性已被破坏
)"
,
userGroup
,
modelRequest
.
Model
))
abortWithOpenAiMessage
(
c
,
http
.
StatusServiceUnavailable
,
fmt
.
Sprintf
(
"
分组 %s 下模型 %s 的可用渠道不存在(数据库一致性已被破坏,distributor
)"
,
userGroup
,
modelRequest
.
Model
))
return
}
}
...
...
model/channel_cache.go
View file @
5418bb3b
...
...
@@ -109,9 +109,6 @@ func CacheGetRandomSatisfiedChannel(c *gin.Context, group string, model string,
return
nil
,
group
,
err
}
}
if
channel
==
nil
{
return
nil
,
group
,
errors
.
New
(
"channel not found"
)
}
return
channel
,
selectGroup
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment