chore: opt video channel and platform - #1416
Conversation
WalkthroughThis change removes explicit support for the "kling" and "jimeng" task platforms and their associated relay modes, consolidating their handling into generic video-related constants, logic, and UI rendering. Platform-specific functions, constants, and code paths are deleted or refactored to use unified video platform handling across backend and frontend components. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Middleware
participant Controller
participant Relay
participant TaskAdaptor
Client->>Middleware: Request (POST/GET /v1/video/generations)
Middleware->>Controller: Set relay mode (VideoSubmit/VideoFetchByID)
Controller->>Relay: taskRelayHandler (relay mode)
Relay->>Relay: GetTaskPlatform (from context)
Relay->>TaskAdaptor: GetTaskAdaptor (platform)
TaskAdaptor-->>Relay: Adaptor instance
Relay->>Controller: Processed result
Controller->>Client: Response
Estimated code review effort3 (~40 minutes) Possibly related PRs
Suggested reviewers
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 (8)
constant/task.go(0 hunks)controller/relay.go(1 hunks)controller/task.go(1 hunks)middleware/distributor.go(1 hunks)relay/constant/relay_mode.go(1 hunks)relay/relay_adaptor.go(3 hunks)relay/relay_task.go(2 hunks)web/src/components/table/task-logs/TaskLogsColumnDefs.js(2 hunks)
🧠 Learnings (2)
controller/relay.go (1)
Learnt from: 9Ninety
PR: #1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
relay/relay_adaptor.go (1)
Learnt from: 9Ninety
PR: #1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
🧬 Code Graph Analysis (5)
relay/relay_task.go (2)
relay/relay_adaptor.go (1)
GetTaskPlatform(104-110)relay/constant/relay_mode.go (1)
RelayModeVideoFetchByID(43-43)
controller/relay.go (1)
relay/constant/relay_mode.go (3)
RelayModeSunoFetch(39-39)RelayModeSunoFetchByID(40-40)RelayModeVideoFetchByID(43-43)
controller/task.go (2)
controller/task_video.go (1)
UpdateVideoTaskAll(18-25)common/logger.go (1)
SysLog(50-53)
relay/relay_adaptor.go (6)
constant/task.go (2)
TaskPlatform(3-3)TaskPlatformSuno(6-6)relay/channel/task/kling/adaptor.go (1)
TaskAdaptor(76-80)relay/channel/adapter.go (1)
TaskAdaptor(31-50)relay/channel/task/suno/adaptor.go (1)
TaskAdaptor(21-23)relay/channel/task/jimeng/adaptor.go (1)
TaskAdaptor(70-75)constant/channel.go (2)
ChannelTypeKling(50-50)ChannelTypeJimeng(51-51)
middleware/distributor.go (1)
relay/constant/relay_mode.go (3)
RelayModeUnknown(9-9)RelayModeVideoSubmit(44-44)RelayModeVideoFetchByID(43-43)
💤 Files with no reviewable changes (1)
- constant/task.go
🧰 Additional context used
🧠 Learnings (2)
controller/relay.go (1)
Learnt from: 9Ninety
PR: #1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
relay/relay_adaptor.go (1)
Learnt from: 9Ninety
PR: #1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
🧬 Code Graph Analysis (5)
relay/relay_task.go (2)
relay/relay_adaptor.go (1)
GetTaskPlatform(104-110)relay/constant/relay_mode.go (1)
RelayModeVideoFetchByID(43-43)
controller/relay.go (1)
relay/constant/relay_mode.go (3)
RelayModeSunoFetch(39-39)RelayModeSunoFetchByID(40-40)RelayModeVideoFetchByID(43-43)
controller/task.go (2)
controller/task_video.go (1)
UpdateVideoTaskAll(18-25)common/logger.go (1)
SysLog(50-53)
relay/relay_adaptor.go (6)
constant/task.go (2)
TaskPlatform(3-3)TaskPlatformSuno(6-6)relay/channel/task/kling/adaptor.go (1)
TaskAdaptor(76-80)relay/channel/adapter.go (1)
TaskAdaptor(31-50)relay/channel/task/suno/adaptor.go (1)
TaskAdaptor(21-23)relay/channel/task/jimeng/adaptor.go (1)
TaskAdaptor(70-75)constant/channel.go (2)
ChannelTypeKling(50-50)ChannelTypeJimeng(51-51)
middleware/distributor.go (1)
relay/constant/relay_mode.go (3)
RelayModeUnknown(9-9)RelayModeVideoSubmit(44-44)RelayModeVideoFetchByID(43-43)
🔇 Additional comments (11)
web/src/components/table/task-logs/TaskLogsColumnDefs.js (1)
125-132: Excellent consolidation of platform rendering logic.The dynamic approach using
CHANNEL_OPTIONSis much more maintainable than hardcoded platform cases. The consistent use of theVideoicon for all matched video platforms provides a unified user experience.relay/relay_task.go (2)
27-29: Good defensive programming with platform fallback.The fallback to
GetTaskPlatform(c)when the platform string is empty ensures robust platform determination. This aligns well with the unified platform resolution approach described in the AI summary.
184-184: Relay mode consolidation is consistent with the refactor.Replacing
RelayModeKlingFetchByIDwithRelayModeVideoFetchByIDsuccessfully unifies the video platform handling as intended by this PR.controller/relay.go (1)
431-431: Switch case update aligns with unified video handling.The replacement of platform-specific relay mode with
RelayModeVideoFetchByIDis consistent with the broader consolidation effort and maintains the same functional behavior.controller/task.go (1)
79-81: Good consolidation with improved error handling.Moving
UpdateVideoTaskAllto the default case effectively handles all video platforms (including the previously explicit kling/jimeng cases) while adding proper error logging that was missing before. This is both a simplification and an improvement.middleware/distributor.go (1)
177-183: Excellent simplification of video generation request handling.The new approach is much cleaner:
- Direct HTTP method-based relay mode assignment eliminates complex platform-specific parsing
- Setting
shouldSelectChannel = falsefor GET requests (fetch operations) is appropriate- Removes dependency on model name prefixes for platform determination
This change successfully achieves the PR objective of unifying video channel preprocessing logic.
relay/constant/relay_mode.go (1)
43-44: LGTM! Good consolidation of platform-specific relay modes.The unified
RelayModeVideoFetchByIDandRelayModeVideoSubmitconstants effectively replace the platform-specific Kling and Jimeng relay modes, simplifying the codebase while maintaining functionality.relay/relay_adaptor.go (4)
4-4: Import addition looks good.The
github.com/gin-gonic/ginimport is needed for the newGetTaskPlatformfunction.
37-37: Import addition looks good.The
strconvimport is needed for the integer-to-string conversions in the new platform handling logic.
112-128: The unified platform handling approach is well-designed.The refactored
GetTaskAdaptorfunction effectively handles the transition from platform-specific constants to a more flexible approach. The fallback to numeric channel type parsing maintains backward compatibility while supporting the unified video platform approach.The logic correctly:
- Handles the explicit
TaskPlatformSunocase- Attempts to parse the platform as an integer for numeric channel types
- Maps
ChannelTypeKlingandChannelTypeJimengto their respective adaptors
104-110: Ignore platform extraction inconsistency concernI verified that
GetTaskPlatformreturns a numeric string whenchannel_typeis set, and theNewTaskAdaptorlogic first parses that numeric string back to an integer to route to the proper channel adaptor. If parsing fails, it falls back to the string constants ("suno","mj", etc.). No other parts of the code compare the rawplatformstring in a way that would break under this dual representation, so the existing logic is consistent and no changes are needed.Likely an incorrect or invalid review comment.
| Sparkles | ||
| } from 'lucide-react'; | ||
| import { TASK_ACTION_GENERATE, TASK_ACTION_TEXT_GENERATE } from '../../../constants/common.constant'; | ||
| import { CHANNEL_OPTIONS } from '../../../constants/channel.constants'; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify CHANNEL_OPTIONS import and usage.
Ensure that the imported CHANNEL_OPTIONS from channel.constants contains the expected video platform entries with proper value, label, and color properties.
🏁 Script executed:
#!/bin/bash
# Description: Verify CHANNEL_OPTIONS structure and content for video platforms
# Expected: Find CHANNEL_OPTIONS export with video platform configurations
echo "Searching for CHANNEL_OPTIONS definition:"
fd -e js -e ts -e jsx -e tsx channel.constants --exec cat {} \; | grep -A 20 "CHANNEL_OPTIONS"
echo -e "\nSearching for video platform references in constants:"
rg -A 5 -B 5 "video|Video|kling|jimeng" --type js --type tsLength of output: 9039
CHANNEL_OPTIONS missing video platform entries
It looks like CHANNEL_OPTIONS (in web/src/constants/channel.constants.js) currently only includes providers such as OpenAI, Midjourney Proxy, Suno API, Ollama, etc., but no entries for our video platforms (e.g. Kling, Jimeng). The renderPlatform function in TaskLogsColumnDefs.js uses these options to render the correct tag, so we need to add the missing video‐task channels.
Please update web/src/constants/channel.constants.js to include the video platform entries with unique values, descriptive labels, and appropriate colors. For example:
export const CHANNEL_OPTIONS = [
{ value: 1, color: 'green', label: 'OpenAI' },
{ value: 2, color: 'light-blue', label: 'Midjourney Proxy' },
{ value: 5, color: 'blue', label: 'Midjourney Proxy Plus' },
{ value: 36, color: 'purple', label: 'Suno API' },
{ value: 4, color: 'grey', label: 'Ollama' },
{ value: 14, color: 'indigo', label: '…' },
+ { value: XX, color: 'orange', label: 'Kling' },
+ { value: YY, color: 'teal', label: 'Jimeng' },
// …any other channels
];• Ensure each new entry has a unique numeric value.
• Pick distinct, accessible color strings.
• Match the label exactly to how you want it displayed in the UI.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In web/src/constants/channel.constants.js, add new entries for the missing video
platforms such as Kling and Jimeng to the CHANNEL_OPTIONS array. Each entry
should have a unique numeric value, a label matching the platform name exactly
as it should appear in the UI, and an accessible color string distinct from
existing entries. This will ensure the renderPlatform function in
TaskLogsColumnDefs.js can correctly display tags for these video platforms.
…nnel chore: opt video channel and platform
优化视频渠道代码:
Summary by CodeRabbit