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
Unverified
Commit
87cc22d7
authored
Jun 04, 2026
by
Rain
Committed by
GitHub
Jun 04, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(distributor): resolve model for GET /v1/video/generations/:task_id (#5133)
parent
3aa113b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
middleware/distributor.go
+27
-0
No files found.
middleware/distributor.go
View file @
87cc22d7
...
@@ -298,6 +298,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
...
@@ -298,6 +298,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
shouldSelectChannel
=
false
shouldSelectChannel
=
false
modelRequest
.
Model
=
getTaskOriginModelName
(
c
)
}
}
c
.
Set
(
"relay_mode"
,
relayMode
)
c
.
Set
(
"relay_mode"
,
relayMode
)
}
else
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/video/generations"
)
{
}
else
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/video/generations"
)
{
...
@@ -312,6 +313,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
...
@@ -312,6 +313,7 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
shouldSelectChannel
=
false
shouldSelectChannel
=
false
modelRequest
.
Model
=
getTaskOriginModelName
(
c
)
}
}
if
_
,
ok
:=
c
.
Get
(
"relay_mode"
);
!
ok
{
if
_
,
ok
:=
c
.
Get
(
"relay_mode"
);
!
ok
{
c
.
Set
(
"relay_mode"
,
relayMode
)
c
.
Set
(
"relay_mode"
,
relayMode
)
...
@@ -396,6 +398,31 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
...
@@ -396,6 +398,31 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
return
&
modelRequest
,
shouldSelectChannel
,
nil
return
&
modelRequest
,
shouldSelectChannel
,
nil
}
}
// 修复 #4834: GET /v1/video/generations/:task_id && /v1/video/:task_id 此前不解析 model,
// 当 token 启用「可用模型限制」时,下游 modelLimitEnable 校验会因
// modelRequest.Model 为空而误报 "This token has no access to model"。
// 从已存储的任务记录中回填 OriginModelName 即可让校验走在正确的模型上。
func
getTaskOriginModelName
(
c
*
gin
.
Context
)
string
{
if
!
common
.
GetContextKeyBool
(
c
,
constant
.
ContextKeyTokenModelLimitEnabled
)
{
return
""
}
taskId
:=
c
.
Param
(
"task_id"
)
if
taskId
==
""
{
// jimeng adapter
taskId
=
c
.
GetString
(
"task_id"
)
}
if
taskId
==
""
{
return
""
}
userId
:=
c
.
GetInt
(
"id"
)
if
task
,
exist
,
err
:=
model
.
GetByTaskId
(
userId
,
taskId
);
err
==
nil
&&
exist
&&
task
!=
nil
{
return
task
.
Properties
.
OriginModelName
}
return
""
}
func
SetupContextForSelectedChannel
(
c
*
gin
.
Context
,
channel
*
model
.
Channel
,
modelName
string
)
*
types
.
NewAPIError
{
func
SetupContextForSelectedChannel
(
c
*
gin
.
Context
,
channel
*
model
.
Channel
,
modelName
string
)
*
types
.
NewAPIError
{
c
.
Set
(
"original_model"
,
modelName
)
// for retry
c
.
Set
(
"original_model"
,
modelName
)
// for retry
if
channel
==
nil
{
if
channel
==
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