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
b3c4d972
authored
Jul 22, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: opt video channel and platform
parent
2f55960b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
66 deletions
+45
-66
constant/task.go
+0
-2
controller/relay.go
+1
-1
controller/task.go
+3
-3
middleware/distributor.go
+6
-15
relay/constant/relay_mode.go
+2
-25
relay/relay_adaptor.go
+20
-7
relay/relay_task.go
+4
-1
web/src/components/table/task-logs/TaskLogsColumnDefs.js
+9
-12
No files found.
constant/task.go
View file @
b3c4d972
...
...
@@ -5,8 +5,6 @@ type TaskPlatform string
const
(
TaskPlatformSuno
TaskPlatform
=
"suno"
TaskPlatformMidjourney
=
"mj"
TaskPlatformKling
TaskPlatform
=
"kling"
TaskPlatformJimeng
TaskPlatform
=
"jimeng"
)
const
(
...
...
controller/relay.go
View file @
b3c4d972
...
...
@@ -428,7 +428,7 @@ func RelayTask(c *gin.Context) {
func
taskRelayHandler
(
c
*
gin
.
Context
,
relayMode
int
)
*
dto
.
TaskError
{
var
err
*
dto
.
TaskError
switch
relayMode
{
case
relayconstant
.
RelayModeSunoFetch
,
relayconstant
.
RelayModeSunoFetchByID
,
relayconstant
.
RelayMode
Kling
FetchByID
:
case
relayconstant
.
RelayModeSunoFetch
,
relayconstant
.
RelayModeSunoFetchByID
,
relayconstant
.
RelayMode
Video
FetchByID
:
err
=
relay
.
RelayTaskFetch
(
c
,
relayMode
)
default
:
err
=
relay
.
RelayTaskSubmit
(
c
,
relayMode
)
...
...
controller/task.go
View file @
b3c4d972
...
...
@@ -75,10 +75,10 @@ func UpdateTaskByPlatform(platform constant.TaskPlatform, taskChannelM map[int][
//_ = UpdateMidjourneyTaskAll(context.Background(), tasks)
case
constant
.
TaskPlatformSuno
:
_
=
UpdateSunoTaskAll
(
context
.
Background
(),
taskChannelM
,
taskM
)
case
constant
.
TaskPlatformKling
,
constant
.
TaskPlatformJimeng
:
_
=
UpdateVideoTaskAll
(
context
.
Background
(),
platform
,
taskChannelM
,
taskM
)
default
:
common
.
SysLog
(
"未知平台"
)
if
err
:=
UpdateVideoTaskAll
(
context
.
Background
(),
platform
,
taskChannelM
,
taskM
);
err
!=
nil
{
common
.
SysLog
(
fmt
.
Sprintf
(
"UpdateVideoTaskAll fail: %s"
,
err
))
}
}
}
...
...
middleware/distributor.go
View file @
b3c4d972
...
...
@@ -174,22 +174,13 @@ func getModelRequest(c *gin.Context) (*ModelRequest, bool, error) {
c
.
Set
(
"relay_mode"
,
relayMode
)
}
else
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/video/generations"
)
{
err
=
common
.
UnmarshalBodyReusable
(
c
,
&
modelRequest
)
var
platform
string
var
relayMode
int
if
strings
.
HasPrefix
(
modelRequest
.
Model
,
"jimeng"
)
{
platform
=
string
(
constant
.
TaskPlatformJimeng
)
relayMode
=
relayconstant
.
Path2RelayJimeng
(
c
.
Request
.
Method
,
c
.
Request
.
URL
.
Path
)
if
relayMode
==
relayconstant
.
RelayModeJimengFetchByID
{
shouldSelectChannel
=
false
}
}
else
{
platform
=
string
(
constant
.
TaskPlatformKling
)
relayMode
=
relayconstant
.
Path2RelayKling
(
c
.
Request
.
Method
,
c
.
Request
.
URL
.
Path
)
if
relayMode
==
relayconstant
.
RelayModeKlingFetchByID
{
shouldSelectChannel
=
false
}
relayMode
:=
relayconstant
.
RelayModeUnknown
if
c
.
Request
.
Method
==
http
.
MethodPost
{
relayMode
=
relayconstant
.
RelayModeVideoSubmit
}
else
if
c
.
Request
.
Method
==
http
.
MethodGet
{
relayMode
=
relayconstant
.
RelayModeVideoFetchByID
shouldSelectChannel
=
false
}
c
.
Set
(
"platform"
,
platform
)
c
.
Set
(
"relay_mode"
,
relayMode
)
}
else
if
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1beta/models/"
)
||
strings
.
HasPrefix
(
c
.
Request
.
URL
.
Path
,
"/v1/models/"
)
{
// Gemini API 路径处理: /v1beta/models/gemini-2.0-flash:generateContent
...
...
relay/constant/relay_mode.go
View file @
b3c4d972
...
...
@@ -40,11 +40,8 @@ const (
RelayModeSunoFetchByID
RelayModeSunoSubmit
RelayModeKlingFetchByID
RelayModeKlingSubmit
RelayModeJimengFetchByID
RelayModeJimengSubmit
RelayModeVideoFetchByID
RelayModeVideoSubmit
RelayModeRerank
...
...
@@ -145,23 +142,3 @@ func Path2RelaySuno(method, path string) int {
}
return
relayMode
}
func
Path2RelayKling
(
method
,
path
string
)
int
{
relayMode
:=
RelayModeUnknown
if
method
==
http
.
MethodPost
&&
strings
.
HasSuffix
(
path
,
"/video/generations"
)
{
relayMode
=
RelayModeKlingSubmit
}
else
if
method
==
http
.
MethodGet
&&
(
strings
.
Contains
(
path
,
"/video/generations"
))
{
relayMode
=
RelayModeKlingFetchByID
}
return
relayMode
}
func
Path2RelayJimeng
(
method
,
path
string
)
int
{
relayMode
:=
RelayModeUnknown
if
method
==
http
.
MethodPost
&&
strings
.
HasSuffix
(
path
,
"/video/generations"
)
{
relayMode
=
RelayModeJimengSubmit
}
else
if
method
==
http
.
MethodGet
&&
strings
.
Contains
(
path
,
"/video/generations/"
)
{
relayMode
=
RelayModeJimengFetchByID
}
return
relayMode
}
relay/relay_adaptor.go
View file @
b3c4d972
package
relay
import
(
"github.com/gin-gonic/gin"
"one-api/constant"
commonconstant
"one-api/constant"
"one-api/relay/channel"
"one-api/relay/channel/ali"
"one-api/relay/channel/aws"
...
...
@@ -34,6 +34,7 @@ import (
"one-api/relay/channel/xunfei"
"one-api/relay/channel/zhipu"
"one-api/relay/channel/zhipu_4v"
"strconv"
)
func
GetAdaptor
(
apiType
int
)
channel
.
Adaptor
{
...
...
@@ -100,16 +101,28 @@ func GetAdaptor(apiType int) channel.Adaptor {
return
nil
}
func
GetTaskAdaptor
(
platform
commonconstant
.
TaskPlatform
)
channel
.
TaskAdaptor
{
func
GetTaskPlatform
(
c
*
gin
.
Context
)
constant
.
TaskPlatform
{
channelType
:=
c
.
GetInt
(
"channel_type"
)
if
channelType
>
0
{
return
constant
.
TaskPlatform
(
strconv
.
Itoa
(
channelType
))
}
return
constant
.
TaskPlatform
(
c
.
GetString
(
"platform"
))
}
func
GetTaskAdaptor
(
platform
constant
.
TaskPlatform
)
channel
.
TaskAdaptor
{
switch
platform
{
//case constant.APITypeAIProxyLibrary:
// return &aiproxy.Adaptor{}
case
co
mmonco
nstant
.
TaskPlatformSuno
:
case
constant
.
TaskPlatformSuno
:
return
&
suno
.
TaskAdaptor
{}
case
commonconstant
.
TaskPlatformKling
:
return
&
kling
.
TaskAdaptor
{}
case
commonconstant
.
TaskPlatformJimeng
:
return
&
taskjimeng
.
TaskAdaptor
{}
}
if
channelType
,
err
:=
strconv
.
ParseInt
(
string
(
platform
),
10
,
64
);
err
==
nil
{
switch
channelType
{
case
constant
.
ChannelTypeKling
:
return
&
kling
.
TaskAdaptor
{}
case
constant
.
ChannelTypeJimeng
:
return
&
taskjimeng
.
TaskAdaptor
{}
}
}
return
nil
}
relay/relay_task.go
View file @
b3c4d972
...
...
@@ -24,6 +24,9 @@ Task 任务通过平台、Action 区分任务
*/
func
RelayTaskSubmit
(
c
*
gin
.
Context
,
relayMode
int
)
(
taskErr
*
dto
.
TaskError
)
{
platform
:=
constant
.
TaskPlatform
(
c
.
GetString
(
"platform"
))
if
platform
==
""
{
platform
=
GetTaskPlatform
(
c
)
}
relayInfo
:=
relaycommon
.
GenTaskRelayInfo
(
c
)
adaptor
:=
GetTaskAdaptor
(
platform
)
...
...
@@ -178,7 +181,7 @@ func RelayTaskSubmit(c *gin.Context, relayMode int) (taskErr *dto.TaskError) {
var
fetchRespBuilders
=
map
[
int
]
func
(
c
*
gin
.
Context
)
(
respBody
[]
byte
,
taskResp
*
dto
.
TaskError
){
relayconstant
.
RelayModeSunoFetchByID
:
sunoFetchByIDRespBodyBuilder
,
relayconstant
.
RelayModeSunoFetch
:
sunoFetchRespBodyBuilder
,
relayconstant
.
RelayMode
Kling
FetchByID
:
videoFetchByIDRespBodyBuilder
,
relayconstant
.
RelayMode
Video
FetchByID
:
videoFetchByIDRespBodyBuilder
,
}
func
RelayTaskFetch
(
c
*
gin
.
Context
,
relayMode
int
)
(
taskResp
*
dto
.
TaskError
)
{
...
...
web/src/components/table/task-logs/TaskLogsColumnDefs.js
View file @
b3c4d972
...
...
@@ -39,6 +39,7 @@ import {
Sparkles
}
from
'lucide-react'
;
import
{
TASK_ACTION_GENERATE
,
TASK_ACTION_TEXT_GENERATE
}
from
'../../../constants/common.constant'
;
import
{
CHANNEL_OPTIONS
}
from
'../../../constants/channel.constants'
;
const
colors
=
[
'amber'
,
...
...
@@ -121,6 +122,14 @@ const renderType = (type, t) => {
};
const
renderPlatform
=
(
platform
,
t
)
=>
{
let
option
=
CHANNEL_OPTIONS
.
find
(
opt
=>
String
(
opt
.
value
)
===
String
(
platform
));
if
(
option
)
{
return
(
<
Tag
color
=
{
option
.
color
}
shape
=
'circle'
prefixIcon
=
{
<
Video
size
=
{
14
}
/>}
>
{
option
.
label
}
<
/Tag
>
);
}
switch
(
platform
)
{
case
'suno'
:
return
(
...
...
@@ -128,18 +137,6 @@ const renderPlatform = (platform, t) => {
Suno
<
/Tag
>
);
case
'kling'
:
return
(
<
Tag
color
=
'orange'
shape
=
'circle'
prefixIcon
=
{
<
Video
size
=
{
14
}
/>}
>
Kling
<
/Tag
>
);
case
'jimeng'
:
return
(
<
Tag
color
=
'purple'
shape
=
'circle'
prefixIcon
=
{
<
Video
size
=
{
14
}
/>}
>
Jimeng
<
/Tag
>
);
default
:
return
(
<
Tag
color
=
'white'
shape
=
'circle'
prefixIcon
=
{
<
HelpCircle
size
=
{
14
}
/>}
>
...
...
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