Repository navigation
feat: add kling video text2Video when image is empty - #1399
Conversation
WalkthroughA conditional check was added to the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant TaskAdaptor
participant GinContext
Client->>TaskAdaptor: BuildRequestBody(request, ctx)
TaskAdaptor->>TaskAdaptor: Convert request to requestPayload
TaskAdaptor->>TaskAdaptor: Check if Image and ImageTail are empty
alt Both are empty
TaskAdaptor->>GinContext: Set "action" = TaskActionTextGenerate
end
TaskAdaptor->>TaskAdaptor: Marshal payload to JSON
TaskAdaptor-->>Client: Return marshalled payload
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/task/kling/adaptor.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
relay/channel/task/kling/adaptor.go (1)
constant/task.go (1)
TaskActionTextGenerate(17-17)
| if body.Image == "" && body.ImageTail == "" { | ||
| c.Set("action", constant.TaskActionTextGenerate) | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Critical: Reference to undefined field ImageTail
The condition checks body.ImageTail but the requestPayload struct (lines 40-48) doesn't define an ImageTail field. This will cause a compilation error.
The logic to switch to text generation when no images are provided is sound, but the implementation references a non-existent field. Apply this fix:
- if body.Image == "" && body.ImageTail == "" {
+ if body.Image == "" {
c.Set("action", constant.TaskActionTextGenerate)
}Alternatively, if ImageTail is a required field for the functionality, add it to the requestPayload struct:
type requestPayload struct {
Prompt string `json:"prompt,omitempty"`
Image string `json:"image,omitempty"`
+ ImageTail string `json:"image_tail,omitempty"`
Mode string `json:"mode,omitempty"`
Duration string `json:"duration,omitempty"`
AspectRatio string `json:"aspect_ratio,omitempty"`
ModelName string `json:"model_name,omitempty"`
CfgScale float64 `json:"cfg_scale,omitempty"`
}Let me verify if ImageTail is used elsewhere in the codebase:
🏁 Script executed:
#!/bin/bash
# Search for ImageTail usage in the codebase
rg -i "imagetail" --type go -A 2 -B 2Length of output: 339
🏁 Script executed:
#!/bin/bash
# Show definition of requestPayload to verify fields
rg -n "type requestPayload" -A 5 -B 5 relay/channel/task/kling/adaptor.goLength of output: 559
Critical: Undefined ImageTail Field in Conditional
The check at relay/channel/task/kling/adaptor.go (lines 146–148)
if body.Image == "" && body.ImageTail == "" {
c.Set("action", constant.TaskActionTextGenerate)
}references body.ImageTail, but the requestPayload struct has no ImageTail field—this will break compilation.
• To fix, remove the nonexistent field from the condition:
- if body.Image == "" && body.ImageTail == "" {
+ if body.Image == "" {
c.Set("action", constant.TaskActionTextGenerate)
}• If ImageTail is genuinely required, add it to requestPayload:
type requestPayload struct {
Prompt string `json:"prompt,omitempty"`
Image string `json:"image,omitempty"`
+ ImageTail string `json:"image_tail,omitempty"`
Mode string `json:"mode,omitempty"`
Duration string `json:"duration,omitempty"`
AspectRatio string `json:"aspect_ratio,omitempty"`
}🤖 Prompt for AI Agents
In relay/channel/task/kling/adaptor.go around lines 146 to 148, the condition
references body.ImageTail, which does not exist in the requestPayload struct and
causes a compilation error. To fix this, either remove the check for
body.ImageTail from the if condition or, if the field is needed, add ImageTail
to the requestPayload struct definition before using it here.
修复可灵视频参数没有图片时报错问题
当首图和尾图都为空时改调文生图接口
Summary by CodeRabbit