mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 04:22:58 +00:00
* feat: add ali wan video * refactor: use same UnmarshalBodyReusable * feat: enhance request body metadata * feat: opt wan convertToOpenAIVideo * feat: add wan support other param via json metadata * refactor: remove unused code * fix ali --------- Co-authored-by: feitianbubu <feitianbubu@qq.com>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package dto
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
VideoStatusUnknown = "unknown"
|
|
VideoStatusQueued = "queued"
|
|
VideoStatusInProgress = "in_progress"
|
|
VideoStatusCompleted = "completed"
|
|
VideoStatusFailed = "failed"
|
|
)
|
|
|
|
type OpenAIVideo struct {
|
|
ID string `json:"id"`
|
|
TaskID string `json:"task_id,omitempty"` //兼容旧接口 待废弃
|
|
Object string `json:"object"`
|
|
Model string `json:"model"`
|
|
Status string `json:"status"` // Should use VideoStatus constants: VideoStatusQueued, VideoStatusInProgress, VideoStatusCompleted, VideoStatusFailed
|
|
Progress int `json:"progress"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
CompletedAt int64 `json:"completed_at,omitempty"`
|
|
ExpiresAt int64 `json:"expires_at,omitempty"`
|
|
Seconds string `json:"seconds,omitempty"`
|
|
Size string `json:"size,omitempty"`
|
|
RemixedFromVideoID string `json:"remixed_from_video_id,omitempty"`
|
|
Error *OpenAIVideoError `json:"error,omitempty"`
|
|
Metadata map[string]any `json:"metadata,omitempty"`
|
|
}
|
|
|
|
func (m *OpenAIVideo) SetProgressStr(progress string) {
|
|
progress = strings.TrimSuffix(progress, "%")
|
|
m.Progress, _ = strconv.Atoi(progress)
|
|
}
|
|
func (m *OpenAIVideo) SetMetadata(k string, v any) {
|
|
if m.Metadata == nil {
|
|
m.Metadata = make(map[string]any)
|
|
}
|
|
m.Metadata[k] = v
|
|
}
|
|
func NewOpenAIVideo() *OpenAIVideo {
|
|
return &OpenAIVideo{
|
|
Object: "video",
|
|
}
|
|
}
|
|
|
|
type OpenAIVideoError struct {
|
|
Message string `json:"message"`
|
|
Code string `json:"code"`
|
|
}
|