Skip to content

Conversation

@feitianbubu
Copy link
Contributor

@feitianbubu feitianbubu commented Oct 16, 2025

OpeanAI渠道类型支持sora视频生成
防呆设计, sora视频不用专门选择sora渠道, 选择OpenAI就可以正常支持
image

image

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

Updates the JSON tag for OpenAIVideo.Metadata from "meta_data" to "metadata" and adds ChannelTypeOpenAI case to GetTaskAdaptor that returns a tasksora.TaskAdaptor, aligning OpenAI channel handling with Sora task adaptor logic.

Changes

Cohort / File(s) Change Summary
JSON Serialization Tag Update
dto/openai_video.go
Changes JSON tag for Metadata field from "meta_data" to "metadata" to align field serialization with updated key naming convention.
Channel Type Adaptor Mapping
relay/relay_adaptor.go
Adds ChannelTypeOpenAI case to GetTaskAdaptor switch statement that returns &tasksora.TaskAdaptor{}, enabling OpenAI channels to use the same task adaptor as Sora channels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A metadata key renamed with care,
And OpenAI joins Sora's affair,
The adaptors align, all tidy and neat—
JSON tags dancing, the refactor's complete! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Pr/OpenAI channel type support sora" directly corresponds to the main change in the pull request: adding a new case in relay/relay_adaptor.go to handle ChannelTypeOpenAI by returning the same tasksora.TaskAdaptor used for Sora. This allows OpenAI channel type to generate Sora videos, which aligns perfectly with the stated PR objectives. The title is specific and clearly communicates that this change enables OpenAI channel type support for Sora video generation, and it avoids vague or generic phrasing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcf93a2 and ed0b418.

📒 Files selected for processing (2)
  • dto/openai_video.go (1 hunks)
  • relay/relay_adaptor.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
relay/relay_adaptor.go (3)
constant/channel.go (1)
  • ChannelTypeOpenAI (5-5)
relay/channel/adapter.go (1)
  • TaskAdaptor (34-53)
relay/channel/task/sora/adaptor.go (1)
  • TaskAdaptor (58-62)
🔇 Additional comments (1)
dto/openai_video.go (1)

30-30: The review comment is incorrect—no JSON tag change is occurring in this PR.

The Metadata field already uses json:"metadata,omitempty" in the HEAD version (before this PR). The git history confirms this is the current state, not a change being introduced. There is no breaking change to flag.

Likely an incorrect or invalid review comment.

Comment on lines +144 to +145
case constant.ChannelTypeOpenAI:
return &tasksora.TaskAdaptor{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

LGTM! Verify TaskAdaptor handles both channel types correctly.

The addition of ChannelTypeOpenAI to use tasksora.TaskAdaptor aligns with the PR objective. However, ensure that the TaskAdaptor implementation properly handles both Sora and OpenAI channel types.

Run the following script to verify the TaskAdaptor implementation:

Additionally, verify:

  1. Does the Init method properly set the ChannelType field from RelayInfo?
  2. Are there any conditional branches in TaskAdaptor that assume only Sora channel type?
  3. Do the base URL and API key configurations work correctly for OpenAI channels?

🏁 Script executed:

#!/bin/bash
# Description: Verify TaskAdaptor handles both channel types correctly

# Check TaskAdaptor implementation for channel-type-specific logic
echo "=== Checking TaskAdaptor implementation for channel-type-specific logic ==="
rg -n --type go -A 5 -B 2 'ChannelType.*Sora|ChannelType.*OpenAI' relay/channel/task/sora/

# Check Init method implementation
echo -e "\n=== Checking Init method implementation ==="
ast-grep --pattern 'func ($_ *TaskAdaptor) Init($$$) {
  $$$
}'

# Check for any hardcoded Sora assumptions
echo -e "\n=== Checking for hardcoded Sora references ==="
rg -n --type go -i 'sora' relay/channel/task/sora/ | head -20

Length of output: 2809


Implement a dedicated OpenAI TaskAdaptor instead of reusing the Sora TaskAdaptor. The Sora adaptor (relay/channel/task/sora/adaptor.go) contains Sora-specific parsing and constants and won’t handle OpenAI responses correctly.

🤖 Prompt for AI Agents
In relay/relay_adaptor.go around lines 144-145, the switch currently returns the
Sora TaskAdaptor for constant.ChannelTypeOpenAI which is incorrect; replace this
by creating and returning a dedicated OpenAI TaskAdaptor. Implement a new
adaptor at relay/channel/task/openai/adaptor.go that mirrors the TaskAdaptor
interface used by other channels but contains OpenAI-specific parsing, response
mapping, and constants (separate types/consts from Sora), export a constructor
(e.g., NewTaskAdaptor or TaskAdaptor struct) and update relay/relay_adaptor.go
to import that package and return its instance for ChannelTypeOpenAI; also
update imports and add unit tests exercising OpenAI parsing to ensure behavior
differs from Sora where needed.

@seefs001
Copy link
Collaborator

现在的代码已经有这个OpenAI渠道自带sora视频生成的内容了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants