mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 02:25:00 +00:00
feat: add remixGenerate const
This commit is contained in:
@@ -15,6 +15,7 @@ const (
|
|||||||
TaskActionTextGenerate = "textGenerate"
|
TaskActionTextGenerate = "textGenerate"
|
||||||
TaskActionFirstTailGenerate = "firstTailGenerate"
|
TaskActionFirstTailGenerate = "firstTailGenerate"
|
||||||
TaskActionReferenceGenerate = "referenceGenerate"
|
TaskActionReferenceGenerate = "referenceGenerate"
|
||||||
|
TaskActionRemix = "remixGenerate"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SunoModel2Action = map[string]string{
|
var SunoModel2Action = map[string]string{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/QuantumNous/new-api/common"
|
"github.com/QuantumNous/new-api/common"
|
||||||
|
"github.com/QuantumNous/new-api/constant"
|
||||||
"github.com/QuantumNous/new-api/dto"
|
"github.com/QuantumNous/new-api/dto"
|
||||||
"github.com/QuantumNous/new-api/model"
|
"github.com/QuantumNous/new-api/model"
|
||||||
"github.com/QuantumNous/new-api/relay/channel"
|
"github.com/QuantumNous/new-api/relay/channel"
|
||||||
@@ -82,14 +83,14 @@ func validateRemixRequest(c *gin.Context) *dto.TaskError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.TaskError) {
|
func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.TaskError) {
|
||||||
if info.Action == "remix" {
|
if info.Action == constant.TaskActionRemix {
|
||||||
return validateRemixRequest(c)
|
return validateRemixRequest(c)
|
||||||
}
|
}
|
||||||
return relaycommon.ValidateMultipartDirect(c, info)
|
return relaycommon.ValidateMultipartDirect(c, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *TaskAdaptor) BuildRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *TaskAdaptor) BuildRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
if info.Action == "remix" {
|
if info.Action == constant.TaskActionRemix {
|
||||||
return fmt.Sprintf("%s/v1/videos/%s/remix", a.baseURL, info.OriginTaskID), nil
|
return fmt.Sprintf("%s/v1/videos/%s/remix", a.baseURL, info.OriginTaskID), nil
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s/v1/videos", a.baseURL), nil
|
return fmt.Sprintf("%s/v1/videos", a.baseURL), nil
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.
|
|||||||
}
|
}
|
||||||
path := c.Request.URL.Path
|
path := c.Request.URL.Path
|
||||||
if strings.Contains(path, "/v1/videos/") && strings.HasSuffix(path, "/remix") {
|
if strings.Contains(path, "/v1/videos/") && strings.HasSuffix(path, "/remix") {
|
||||||
info.Action = "remix"
|
info.Action = constant.TaskActionRemix
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提取 remix 任务的 video_id
|
// 提取 remix 任务的 video_id
|
||||||
if info.Action == "remix" {
|
if info.Action == constant.TaskActionRemix {
|
||||||
videoID := c.Param("video_id")
|
videoID := c.Param("video_id")
|
||||||
if strings.TrimSpace(videoID) == "" {
|
if strings.TrimSpace(videoID) == "" {
|
||||||
return service.TaskErrorWrapperLocal(fmt.Errorf("video_id is required"), "invalid_request", http.StatusBadRequest)
|
return service.TaskErrorWrapperLocal(fmt.Errorf("video_id is required"), "invalid_request", http.StatusBadRequest)
|
||||||
@@ -93,7 +93,7 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用原始任务的参数
|
// 使用原始任务的参数
|
||||||
if info.Action == "remix" {
|
if info.Action == constant.TaskActionRemix {
|
||||||
var taskData map[string]interface{}
|
var taskData map[string]interface{}
|
||||||
_ = json.Unmarshal(originTask.Data, &taskData)
|
_ = json.Unmarshal(originTask.Data, &taskData)
|
||||||
secondsStr, _ := taskData["seconds"].(string)
|
secondsStr, _ := taskData["seconds"].(string)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import {
|
|||||||
TASK_ACTION_GENERATE,
|
TASK_ACTION_GENERATE,
|
||||||
TASK_ACTION_REFERENCE_GENERATE,
|
TASK_ACTION_REFERENCE_GENERATE,
|
||||||
TASK_ACTION_TEXT_GENERATE,
|
TASK_ACTION_TEXT_GENERATE,
|
||||||
|
TASK_ACTION_REMIX_GENERATE,
|
||||||
} from '../../../constants/common.constant';
|
} from '../../../constants/common.constant';
|
||||||
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
|
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
|
||||||
|
|
||||||
@@ -125,6 +126,12 @@ const renderType = (type, t) => {
|
|||||||
{t('参照生视频')}
|
{t('参照生视频')}
|
||||||
</Tag>
|
</Tag>
|
||||||
);
|
);
|
||||||
|
case TASK_ACTION_REMIX_GENERATE:
|
||||||
|
return (
|
||||||
|
<Tag color='blue' shape='circle' prefixIcon={<Sparkles size={14} />}>
|
||||||
|
{t('remix生视频')}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<Tag color='white' shape='circle' prefixIcon={<HelpCircle size={14} />}>
|
<Tag color='white' shape='circle' prefixIcon={<HelpCircle size={14} />}>
|
||||||
@@ -359,7 +366,8 @@ export const getTaskLogsColumns = ({
|
|||||||
record.action === TASK_ACTION_GENERATE ||
|
record.action === TASK_ACTION_GENERATE ||
|
||||||
record.action === TASK_ACTION_TEXT_GENERATE ||
|
record.action === TASK_ACTION_TEXT_GENERATE ||
|
||||||
record.action === TASK_ACTION_FIRST_TAIL_GENERATE ||
|
record.action === TASK_ACTION_FIRST_TAIL_GENERATE ||
|
||||||
record.action === TASK_ACTION_REFERENCE_GENERATE;
|
record.action === TASK_ACTION_REFERENCE_GENERATE ||
|
||||||
|
record.action === TASK_ACTION_REMIX_GENERATE;
|
||||||
const isSuccess = record.status === 'SUCCESS';
|
const isSuccess = record.status === 'SUCCESS';
|
||||||
const isUrl = typeof text === 'string' && /^https?:\/\//.test(text);
|
const isUrl = typeof text === 'string' && /^https?:\/\//.test(text);
|
||||||
if (isSuccess && isVideoTask && isUrl) {
|
if (isSuccess && isVideoTask && isUrl) {
|
||||||
|
|||||||
@@ -42,3 +42,4 @@ export const TASK_ACTION_GENERATE = 'generate';
|
|||||||
export const TASK_ACTION_TEXT_GENERATE = 'textGenerate';
|
export const TASK_ACTION_TEXT_GENERATE = 'textGenerate';
|
||||||
export const TASK_ACTION_FIRST_TAIL_GENERATE = 'firstTailGenerate';
|
export const TASK_ACTION_FIRST_TAIL_GENERATE = 'firstTailGenerate';
|
||||||
export const TASK_ACTION_REFERENCE_GENERATE = 'referenceGenerate';
|
export const TASK_ACTION_REFERENCE_GENERATE = 'referenceGenerate';
|
||||||
|
export const TASK_ACTION_REMIX_GENERATE = 'remixGenerate';
|
||||||
|
|||||||
Reference in New Issue
Block a user