Repository navigation
新增Sora视频渠道 - #1988
新增Sora视频渠道#1988
Conversation
WalkthroughAdds Sora video channel support end-to-end: new channel constant, task adaptor, routing for POST /v1/videos and GET /v1/videos/:task_id/content, multipart parsing utilities, reusable multipart form parsing, controller proxy for video content, adaptor initialization update, and minor DTO/UI additions. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as API /v1/videos
participant Dist as Distributor
participant Adaptor as Sora TaskAdaptor
participant Upstream as OpenAI Sora API
Client->>API: POST /v1/videos (multipart)
API->>Dist: Route before auth/distribute
Dist->>Adaptor: ValidateMultipartDirect + Init(RelayInfo)
Adaptor->>Adaptor: BuildRequestURL/Header/Body
Adaptor->>Upstream: POST /v1/videos
Upstream-->>Adaptor: 200 {task_id,...}
Adaptor-->>Client: 200 {task_id}
rect rgba(230,245,255,0.5)
note right of Client: New flow for Sora video submit
end
sequenceDiagram
autonumber
participant Client
participant API as API /v1/videos/:task_id/content
participant Store as Model/Channel Cache
participant Upstream as OpenAI Sora API
Client->>API: GET /v1/videos/:task_id/content
API->>Store: Lookup task, channel, baseURL, key
API->>Upstream: GET /v1/videos/{task_id}/content (Authorization)
Upstream-->>API: Stream (status, headers, body)
API-->>Client: Proxy stream (Cache-Control: public, max-age=86400)
rect rgba(240,255,240,0.5)
note right of API: New proxy endpoint for video content
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
controller/video_proxy.go (1)
117-124: Consider selective header forwarding and proper WriteHeader ordering.Two improvements to consider:
Selective header forwarding (lines 117-121): Copying all headers from the upstream response can include problematic headers like
Transfer-Encoding,Connection,Content-Length(if body size changes), etc. Consider filtering to only forward relevant headers likeContent-Type,Content-Disposition, and custom headers.WriteHeader ordering (line 124):
WriteHeaderis called after setting headers viac.Writer.Header().Add()(lines 117-121), butHeader().Set()is also called on line 123. Ensure headers are set before callingWriteHeaderto avoid issues.Example of selective header forwarding:
- for key, values := range resp.Header { - for _, value := range values { - c.Writer.Header().Add(key, value) - } - } - + // Forward only relevant headers + allowedHeaders := []string{"Content-Type", "Content-Disposition", "Content-Length"} + for _, key := range allowedHeaders { + if values := resp.Header.Values(key); len(values) > 0 { + for _, value := range values { + c.Writer.Header().Add(key, value) + } + } + } c.Writer.Header().Set("Cache-Control", "public, max-age=86400") c.Writer.WriteHeader(resp.StatusCode)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
common/gin.go(2 hunks)constant/channel.go(3 hunks)controller/task_video.go(1 hunks)controller/video_proxy.go(1 hunks)dto/openai_response.go(1 hunks)middleware/distributor.go(1 hunks)relay/channel/task/sora/adaptor.go(1 hunks)relay/channel/task/sora/constants.go(1 hunks)relay/common/relay_utils.go(3 hunks)relay/relay_adaptor.go(2 hunks)router/video-router.go(1 hunks)web/src/constants/channel.constants.js(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
middleware/distributor.go (1)
relay/constant/relay_mode.go (2)
RelayModeUnknown(9-9)RelayModeVideoSubmit(44-44)
controller/task_video.go (1)
relay/common/relay_info.go (2)
RelayInfo(74-121)ChannelMeta(54-72)
relay/relay_adaptor.go (3)
constant/channel.go (1)
ChannelTypeSora(55-55)relay/channel/task/sora/adaptor.go (1)
TaskAdaptor(61-65)relay/channel/adapter.go (1)
TaskAdaptor(32-51)
relay/common/relay_utils.go (3)
relay/common/relay_info.go (2)
RelayInfo(74-121)TaskSubmitReq(484-493)common/gin.go (2)
ParseMultipartFormReusable(118-139)UnmarshalBodyReusable(31-52)constant/task.go (2)
TaskActionTextGenerate(15-15)TaskActionGenerate(14-14)
relay/channel/task/sora/adaptor.go (7)
relay/common/relay_info.go (2)
RelayInfo(74-121)TaskInfo(503-512)relay/common/relay_utils.go (1)
ValidateMultipartDirect(108-133)common/gin.go (1)
GetRequestBody(17-29)relay/channel/api_request.go (1)
DoTaskApiRequest(300-322)service/error.go (1)
TaskErrorWrapper(139-155)relay/channel/task/sora/constants.go (2)
ModelList(3-6)ChannelName(8-8)model/task.go (4)
TaskStatusQueued(16-16)TaskStatusInProgress(17-17)TaskStatusSuccess(19-19)TaskStatusFailure(18-18)
controller/video_proxy.go (3)
model/task.go (2)
GetByOnlyTaskId(184-196)TaskStatusSuccess(19-19)logger/logger.go (1)
LogError(64-66)model/channel_cache.go (1)
CacheGetChannel(212-224)
router/video-router.go (3)
controller/video_proxy.go (1)
VideoProxy(14-129)middleware/auth.go (1)
TokenAuth(178-289)middleware/distributor.go (1)
Distribute(28-123)
🔇 Additional comments (4)
web/src/constants/channel.constants.js (1)
172-176: LGTM! Channel constant addition is correct.The new Sora channel entry with value 55 correctly aligns with the backend constant
ChannelTypeSora = 55defined inconstant/channel.go.router/video-router.go (1)
12-12: Verify the security implications of the unauthenticated video proxy endpoint.The
VideoProxyroute is registered before theTokenAuth()andDistribute()middleware (line 13), making it publicly accessible without authentication. While this may be intentional for serving completed video content, it means anyone with a task ID can access the video.Please confirm:
- Is public access to completed video content intentional?
- Does the task lookup in
VideoProxy(controller/video_proxy.go) provide adequate access control?- Should there be additional checks (e.g., verifying the requester owns the task)?
If public access is not intended, move this route registration to after the middleware:
videoV1Router := router.Group("/v1") - videoV1Router.GET("/videos/:task_id/content", controller.VideoProxy) videoV1Router.Use(middleware.TokenAuth(), middleware.Distribute()) { + videoV1Router.GET("/videos/:task_id/content", controller.VideoProxy) videoV1Router.POST("/video/generations", controller.RelayTask)constant/channel.go (1)
55-55: LGTM! Sora channel constants are correctly defined.The new channel type constant, base URL, and name mapping follow the established pattern and are consistent with the frontend constants.
Also applies to: 116-116, 171-171
relay/common/relay_utils.go (1)
56-56: storeTaskRequest signature change confirmed safe – only caller passes aTaskSubmitReq, so existing calls compile without error.
| func ParseMultipartFormReusable(c *gin.Context) (*multipart.Form, error) { | ||
| requestBody, err := GetRequestBody(c) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| contentType := c.Request.Header.Get("Content-Type") | ||
| boundary := "" | ||
| if idx := strings.Index(contentType, "boundary="); idx != -1 { | ||
| boundary = contentType[idx+9:] | ||
| } | ||
|
|
||
| reader := multipart.NewReader(bytes.NewReader(requestBody), boundary) | ||
| form, err := reader.ReadForm(32 << 20) // 32 MB max memory | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Reset request body | ||
| c.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody)) | ||
| return form, nil | ||
| } |
There was a problem hiding this comment.
Improve boundary extraction to handle standard Content-Type formats.
Lines 124-128 use simplistic string manipulation to extract the boundary from the Content-Type header. This approach has several issues:
- Doesn't handle quoted boundaries:
boundary="----WebKitFormBoundary..." - Doesn't handle additional parameters after the boundary
- Doesn't validate if a boundary was found (when idx == -1, boundary will be empty string)
- Doesn't handle spaces around the equals sign
Use the standard mime.ParseMediaType function for robust parsing:
+import (
+ "mime"
+ // ... other imports
+)
+
func ParseMultipartFormReusable(c *gin.Context) (*multipart.Form, error) {
requestBody, err := GetRequestBody(c)
if err != nil {
return nil, err
}
contentType := c.Request.Header.Get("Content-Type")
- boundary := ""
- if idx := strings.Index(contentType, "boundary="); idx != -1 {
- boundary = contentType[idx+9:]
+ _, params, err := mime.ParseMediaType(contentType)
+ if err != nil {
+ return nil, fmt.Errorf("failed to parse Content-Type: %w", err)
+ }
+ boundary := params["boundary"]
+ if boundary == "" {
+ return nil, fmt.Errorf("boundary not found in Content-Type header")
}
reader := multipart.NewReader(bytes.NewReader(requestBody), boundary)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func ParseMultipartFormReusable(c *gin.Context) (*multipart.Form, error) { | |
| requestBody, err := GetRequestBody(c) | |
| if err != nil { | |
| return nil, err | |
| } | |
| contentType := c.Request.Header.Get("Content-Type") | |
| boundary := "" | |
| if idx := strings.Index(contentType, "boundary="); idx != -1 { | |
| boundary = contentType[idx+9:] | |
| } | |
| reader := multipart.NewReader(bytes.NewReader(requestBody), boundary) | |
| form, err := reader.ReadForm(32 << 20) // 32 MB max memory | |
| if err != nil { | |
| return nil, err | |
| } | |
| // Reset request body | |
| c.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody)) | |
| return form, nil | |
| } | |
| // Add “mime” (and ensure “fmt” is imported) to your import block: | |
| // | |
| // import ( | |
| // "bytes" | |
| // "io" | |
| // "mime" | |
| // "fmt" | |
| // "mime/multipart" | |
| // "strings" | |
| // "github.com/gin-gonic/gin" | |
| // ) | |
| func ParseMultipartFormReusable(c *gin.Context) (*multipart.Form, error) { | |
| requestBody, err := GetRequestBody(c) | |
| if err != nil { | |
| return nil, err | |
| } | |
| contentType := c.Request.Header.Get("Content-Type") | |
| _, params, err := mime.ParseMediaType(contentType) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to parse Content-Type: %w", err) | |
| } | |
| boundary := params["boundary"] | |
| if boundary == "" { | |
| return nil, fmt.Errorf("boundary not found in Content-Type header") | |
| } | |
| reader := multipart.NewReader(bytes.NewReader(requestBody), boundary) | |
| form, err := reader.ReadForm(32 << 20) // 32 MB max memory | |
| if err != nil { | |
| return nil, err | |
| } | |
| // Reset request body | |
| c.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody)) | |
| return form, nil | |
| } |
🤖 Prompt for AI Agents
In common/gin.go around lines 118 to 139, the current boundary extraction uses
manual string indexing which fails for quoted boundaries, extra parameters,
spaces, and missing boundary cases; replace that logic with
mime.ParseMediaType(c.Request.Header.Get("Content-Type")) to parse the media
type and parameters, extract the "boundary" param (it will handle quotes and
spaces), validate that a non-empty boundary exists and return an error if
missing, then pass the boundary to multipart.NewReader; ensure you trim any
surrounding spaces only if needed and keep resetting c.Request.Body as before.
| if !exists || task == nil { | ||
| logger.LogError(c.Request.Context(), fmt.Sprintf("Failed to get task %s: %s", taskID, err.Error())) | ||
| c.JSON(http.StatusNotFound, gin.H{ | ||
| "error": gin.H{ | ||
| "message": "Task not found", | ||
| "type": "invalid_request_error", | ||
| }, | ||
| }) | ||
| return | ||
| } |
There was a problem hiding this comment.
Fix potential nil pointer dereference when logging error.
On line 38, the code logs err.Error() when the task is not found, but err may be nil at this point because the condition is !exists || task == nil. If the task doesn't exist (but there's no database error), err will be nil and calling err.Error() will panic.
Apply this diff to fix the issue:
if !exists || task == nil {
- logger.LogError(c.Request.Context(), fmt.Sprintf("Failed to get task %s: %s", taskID, err.Error()))
+ logger.LogError(c.Request.Context(), fmt.Sprintf("Task not found: %s", taskID))
c.JSON(http.StatusNotFound, gin.H{
"error": gin.H{
"message": "Task not found",
"type": "invalid_request_error",
},
})
return
}
🤖 Prompt for AI Agents
In controller/video_proxy.go around lines 37 to 46, the error logging calls
err.Error() even when err may be nil due to the condition (!exists || task ==
nil); change the log to safely include error details by using a nil-safe
representation (e.g., if err != nil use err.Error() or otherwise use a
descriptive string or fmt.Sprintf("%v", err)) so the logger never dereferences a
nil error, and keep the response behavior the same.
| type OpenAIVideoResponse struct { | ||
| Id string `json:"id" example:"file-abc123"` | ||
| Object string `json:"object" example:"file"` | ||
| Bytes int64 `json:"bytes" example:"120000"` | ||
| CreatedAt int64 `json:"created_at" example:"1677610602"` | ||
| ExpiresAt int64 `json:"expires_at" example:"1677614202"` | ||
| Filename string `json:"filename" example:"mydata.jsonl"` | ||
| Purpose string `json:"purpose" example:"fine-tune"` | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Verify that OpenAIVideoResponse matches the actual API response format.
The struct fields and example tags (e.g., Purpose: "fine-tune", Object: "file") suggest this is a file metadata response rather than a video generation response. According to the PR description, the Sora API returns { "task_id": "4326796003218200779" }, which doesn't match this struct.
Please confirm:
- Is this struct used for the video generation response or for a different endpoint?
- Does the actual Sora video API response match these fields?
- Should there be a separate struct for the task submission response with just
task_id?
Run the following script to check where this struct is used:
🏁 Script executed:
#!/bin/bash
# Search for usage of OpenAIVideoResponse in the codebase
rg -n "OpenAIVideoResponse" --type=go -C3
Length of output: 410
🏁 Script executed:
#!/bin/bash
rg -n 'task_id' -C3 --type=go
Length of output: 27951
Remove unused OpenAIVideoResponse
The struct’s fields reflect file‐upload metadata (id, object, bytes, etc.), not the Sora video task API (which returns only {"task_id": "…"}), and it isn’t referenced anywhere. Use the existing dto.VideoResponse/dto.VideoTaskResponse for video endpoints.
🤖 Prompt for AI Agents
In dto/openai_response.go around lines 236 to 244, remove the unused
OpenAIVideoResponse struct because it models file-upload metadata (id, object,
bytes, created_at, etc.) which doesn't match the Sora video task API and is not
referenced; replace any usages (if present) with the existing dto.VideoResponse
or dto.VideoTaskResponse types and update imports accordingly so no dead types
remain in the package.
| } else if strings.Contains(c.Request.URL.Path, "/v1/videos") { | ||
| //curl https://api.openai.com/v1/videos \ | ||
| // -H "Authorization: Bearer $OPENAI_API_KEY" \ | ||
| // -F "model=sora-2" \ | ||
| // -F "prompt=A calico cat playing a piano on stage" | ||
| // -F input_reference="@image.jpg" | ||
| relayMode := relayconstant.RelayModeUnknown | ||
| if c.Request.Method == http.MethodPost { | ||
| relayMode = relayconstant.RelayModeVideoSubmit | ||
| modelRequest.Model = c.PostForm("model") | ||
| } | ||
| c.Set("relay_mode", relayMode) |
There was a problem hiding this comment.
Fix model extraction for multipart/form-data requests.
On line 177, c.PostForm("model") won't correctly extract the model field from multipart/form-data requests because the multipart form hasn't been parsed yet at this point. The PostForm method only works for URL-encoded forms that are automatically parsed.
For multipart requests, you need to either:
- Call
c.MultipartForm()first to trigger parsing, then accessc.Request.MultipartForm.Value["model"][0] - Use the middleware parsing approach that's already in place for other paths
Apply this diff to fix the issue:
} else if strings.Contains(c.Request.URL.Path, "/v1/videos") {
- //curl https://api.openai.com/v1/videos \
- // -H "Authorization: Bearer $OPENAI_API_KEY" \
- // -F "model=sora-2" \
- // -F "prompt=A calico cat playing a piano on stage"
- // -F input_reference="@image.jpg"
relayMode := relayconstant.RelayModeUnknown
if c.Request.Method == http.MethodPost {
relayMode = relayconstant.RelayModeVideoSubmit
- modelRequest.Model = c.PostForm("model")
+ if strings.Contains(c.Request.Header.Get("Content-Type"), "multipart/form-data") {
+ if form, err := c.MultipartForm(); err == nil && form != nil {
+ if models := form.Value["model"]; len(models) > 0 {
+ modelRequest.Model = models[0]
+ }
+ }
+ } else {
+ modelRequest.Model = c.PostForm("model")
+ }
}
c.Set("relay_mode", relayMode)
🤖 Prompt for AI Agents
In middleware/distributor.go around lines 168 to 179, the code uses
c.PostForm("model") which fails for multipart/form-data; modify the POST
handling so that if the request Content-Type is multipart/form-data you call
c.MultipartForm() (handle the error), then read the model from
c.Request.MultipartForm.Value["model"][0] (with bounds checks) and set
modelRequest.Model to that value; otherwise fall back to c.PostForm("model");
ensure you still set relay_mode and handle missing/empty model safely.
| req.Header.Set("Authorization", "Bearer "+a.apiKey) | ||
| req.Header.Set("Content-Type", c.Request.Header.Get("Content-Type")) | ||
| return nil | ||
| } | ||
|
|
||
| func (a *TaskAdaptor) BuildRequestBody(c *gin.Context, info *relaycommon.RelayInfo) (io.Reader, error) { | ||
| cachedBody, err := common.GetRequestBody(c) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "get_request_body_failed") | ||
| } | ||
| return bytes.NewReader(cachedBody), nil | ||
| } | ||
|
|
||
| // DoRequest delegates to common helper. | ||
| func (a *TaskAdaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (*http.Response, error) { | ||
| return channel.DoTaskApiRequest(a, c, info, requestBody) | ||
| } | ||
|
|
||
| // DoResponse handles upstream response, returns taskID etc. | ||
| func (a *TaskAdaptor) DoResponse(c *gin.Context, resp *http.Response, _ *relaycommon.RelayInfo) (taskID string, taskData []byte, taskErr *dto.TaskError) { | ||
| responseBody, err := io.ReadAll(resp.Body) | ||
| if err != nil { | ||
| taskErr = service.TaskErrorWrapper(err, "read_response_body_failed", http.StatusInternalServerError) | ||
| return | ||
| } | ||
| _ = resp.Body.Close() | ||
|
|
||
| // Parse Sora response | ||
| var dResp responsePayload | ||
| if err := json.Unmarshal(responseBody, &dResp); err != nil { | ||
| taskErr = service.TaskErrorWrapper(errors.Wrapf(err, "body: %s", responseBody), "unmarshal_response_body_failed", http.StatusInternalServerError) | ||
| return | ||
| } | ||
|
|
||
| if dResp.ID == "" { | ||
| taskErr = service.TaskErrorWrapper(fmt.Errorf("task_id is empty"), "invalid_response", http.StatusInternalServerError) | ||
| return | ||
| } | ||
|
|
||
| c.JSON(http.StatusOK, gin.H{"task_id": dResp.ID}) | ||
| return dResp.ID, responseBody, nil | ||
| } | ||
|
|
||
| // FetchTask fetch task status | ||
| func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http.Response, error) { | ||
| taskID, ok := body["task_id"].(string) | ||
| if !ok { | ||
| return nil, fmt.Errorf("invalid task_id") | ||
| } | ||
|
|
||
| uri := fmt.Sprintf("%s/v1/videos/%s", baseUrl, taskID) | ||
|
|
||
| req, err := http.NewRequest(http.MethodGet, uri, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| req.Header.Set("Authorization", "Bearer "+key) | ||
|
|
There was a problem hiding this comment.
Add the required OpenAI-Beta header for all Sora video requests.
OpenAI’s /v1/videos endpoints reject calls that don’t include the OpenAI-Beta marker (e.g. video-generation=2024-09-12). The adaptor currently sets only Authorization/Content-Type, so both the create request and the status polling request will fail with upstream 4xx responses. Please add the mandated OpenAI-Beta header in BuildRequestHeader and FetchTask before we ship.
🤖 Prompt for AI Agents
In relay/channel/task/sora/adaptor.go around lines 83-141, the adaptor currently
only sets Authorization/Content-Type headers but must include the required
OpenAI-Beta marker for Sora video endpoints; add req.Header.Set("OpenAI-Beta",
"video-generation=2024-09-12") in BuildRequestHeader where headers are prepared
and also set the same header on the GET request in FetchTask before sending,
ensuring both create and polling requests include that OpenAI-Beta header.
| func validateMultipartTaskRequest(c *gin.Context, info *RelayInfo, action string) (TaskSubmitReq, error) { | ||
| var req TaskSubmitReq | ||
| if _, err := c.MultipartForm(); err != nil { | ||
| return req, err | ||
| } | ||
|
|
||
| formData := c.Request.PostForm | ||
| req = TaskSubmitReq{ | ||
| Prompt: formData.Get("prompt"), | ||
| Model: formData.Get("model"), | ||
| Mode: formData.Get("mode"), | ||
| Image: formData.Get("image"), | ||
| Size: formData.Get("size"), | ||
| Metadata: make(map[string]interface{}), | ||
| } | ||
|
|
||
| if durationStr := formData.Get("seconds"); durationStr != "" { | ||
| if duration, err := strconv.Atoi(durationStr); err == nil { | ||
| req.Duration = duration | ||
| } | ||
| } | ||
|
|
||
| if images := formData["images"]; len(images) > 0 { | ||
| req.Images = images | ||
| } | ||
|
|
||
| for key, values := range formData { | ||
| if len(values) > 0 && !isKnownTaskField(key) { | ||
| if intVal, err := strconv.Atoi(values[0]); err == nil { | ||
| req.Metadata[key] = intVal | ||
| } else if floatVal, err := strconv.ParseFloat(values[0], 64); err == nil { | ||
| req.Metadata[key] = floatVal | ||
| } else { | ||
| req.Metadata[key] = values[0] | ||
| } | ||
| } | ||
| } | ||
| return req, nil | ||
| } |
There was a problem hiding this comment.
Fix multipart form data extraction to use the correct API.
Lines 70-74 have a critical bug: after calling c.MultipartForm() to parse the multipart form, the code accesses c.Request.PostForm which is for URL-encoded forms, not multipart forms. This means the form data won't be extracted correctly.
For multipart forms, you must use c.Request.MultipartForm.Value instead of c.Request.PostForm.
Apply this diff to fix the form data extraction:
func validateMultipartTaskRequest(c *gin.Context, info *RelayInfo, action string) (TaskSubmitReq, error) {
var req TaskSubmitReq
- if _, err := c.MultipartForm(); err != nil {
+ form, err := c.MultipartForm()
+ if err != nil {
return req, err
}
- formData := c.Request.PostForm
+ formData := form.Value
req = TaskSubmitReq{
Prompt: formData.Get("prompt"),
Model: formData.Get("model"),
Additionally, note the inconsistency on lines 84-88: the code looks for a field named "seconds" but stores it in req.Duration. Consider standardizing on one field name (likely "duration" to match the struct field and the isKnownTaskField list on line 143).
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In relay/common/relay_utils.go around lines 68 to 106, after calling
c.MultipartForm() the code incorrectly reads c.Request.PostForm (URL-encoded
form) so multipart fields aren’t extracted; replace usage with
c.Request.MultipartForm.Value to read form values, ensure images still come from
c.Request.MultipartForm.File if needed, and update the "seconds" handling to use
a consistent "duration" field (or map "seconds" into req.Duration) to match the
TaskSubmitReq struct and isKnownTaskField list.
https://platform.openai.com/docs/api-reference/videos/create, 支持文生视频,图生视频Summary by CodeRabbit