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
d0f13fab
authored
Nov 10, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: vidu specify reference2video via metadata action
parent
48f767f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
21 deletions
+35
-21
relay/channel/task/vidu/adaptor.go
+24
-9
relay/common/relay_utils.go
+11
-12
No files found.
relay/channel/task/vidu/adaptor.go
View file @
d0f13fab
...
...
@@ -82,7 +82,29 @@ func (a *TaskAdaptor) Init(info *relaycommon.RelayInfo) {
}
func
(
a
*
TaskAdaptor
)
ValidateRequestAndSetAction
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
)
*
dto
.
TaskError
{
return
relaycommon
.
ValidateBasicTaskRequest
(
c
,
info
,
constant
.
TaskActionGenerate
)
if
err
:=
relaycommon
.
ValidateBasicTaskRequest
(
c
,
info
,
constant
.
TaskActionGenerate
);
err
!=
nil
{
return
err
}
req
,
err
:=
relaycommon
.
GetTaskRequest
(
c
)
if
err
!=
nil
{
return
service
.
TaskErrorWrapper
(
err
,
"get_task_request_failed"
,
http
.
StatusBadRequest
)
}
action
:=
constant
.
TaskActionTextGenerate
if
meatAction
,
ok
:=
req
.
Metadata
[
"action"
];
ok
{
action
,
_
=
meatAction
.
(
string
)
}
else
if
req
.
HasImage
()
{
action
=
constant
.
TaskActionGenerate
if
info
.
ChannelType
==
constant
.
ChannelTypeVidu
{
// vidu 增加 首尾帧生视频和参考图生视频
if
len
(
req
.
Images
)
==
2
{
action
=
constant
.
TaskActionFirstTailGenerate
}
else
if
len
(
req
.
Images
)
>
2
{
action
=
constant
.
TaskActionReferenceGenerate
}
}
}
info
.
Action
=
action
return
nil
}
func
(
a
*
TaskAdaptor
)
BuildRequestBody
(
c
*
gin
.
Context
,
_
*
relaycommon
.
RelayInfo
)
(
io
.
Reader
,
error
)
{
...
...
@@ -97,10 +119,6 @@ func (a *TaskAdaptor) BuildRequestBody(c *gin.Context, _ *relaycommon.RelayInfo)
return
nil
,
err
}
if
len
(
body
.
Images
)
==
0
{
c
.
Set
(
"action"
,
constant
.
TaskActionTextGenerate
)
}
data
,
err
:=
json
.
Marshal
(
body
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -131,9 +149,6 @@ func (a *TaskAdaptor) BuildRequestHeader(c *gin.Context, req *http.Request, info
}
func
(
a
*
TaskAdaptor
)
DoRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
requestBody
io
.
Reader
)
(
*
http
.
Response
,
error
)
{
if
action
:=
c
.
GetString
(
"action"
);
action
!=
""
{
info
.
Action
=
action
}
return
channel
.
DoTaskApiRequest
(
a
,
c
,
info
,
requestBody
)
}
...
...
@@ -185,7 +200,7 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http
}
func
(
a
*
TaskAdaptor
)
GetModelList
()
[]
string
{
return
[]
string
{
"viduq1"
,
"vidu2.0"
,
"vidu1.5"
}
return
[]
string
{
"viduq
2"
,
"viduq
1"
,
"vidu2.0"
,
"vidu1.5"
}
}
func
(
a
*
TaskAdaptor
)
GetChannelName
()
string
{
...
...
relay/common/relay_utils.go
View file @
d0f13fab
...
...
@@ -59,6 +59,17 @@ func storeTaskRequest(c *gin.Context, info *RelayInfo, action string, requestObj
info
.
Action
=
action
c
.
Set
(
"task_request"
,
requestObj
)
}
func
GetTaskRequest
(
c
*
gin
.
Context
)
(
TaskSubmitReq
,
error
)
{
v
,
exists
:=
c
.
Get
(
"task_request"
)
if
!
exists
{
return
TaskSubmitReq
{},
fmt
.
Errorf
(
"request not found in context"
)
}
req
,
ok
:=
v
.
(
TaskSubmitReq
)
if
!
ok
{
return
TaskSubmitReq
{},
fmt
.
Errorf
(
"invalid task request type"
)
}
return
req
,
nil
}
func
validatePrompt
(
prompt
string
)
*
dto
.
TaskError
{
if
strings
.
TrimSpace
(
prompt
)
==
""
{
...
...
@@ -212,18 +223,6 @@ func ValidateBasicTaskRequest(c *gin.Context, info *RelayInfo, action string) *d
req
.
Images
=
[]
string
{
req
.
Image
}
}
if
req
.
HasImage
()
{
action
=
constant
.
TaskActionGenerate
if
info
.
ChannelType
==
constant
.
ChannelTypeVidu
{
// vidu 增加 首尾帧生视频和参考图生视频
if
len
(
req
.
Images
)
==
2
{
action
=
constant
.
TaskActionFirstTailGenerate
}
else
if
len
(
req
.
Images
)
>
2
{
action
=
constant
.
TaskActionReferenceGenerate
}
}
}
storeTaskRequest
(
c
,
info
,
action
,
req
)
return
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