Skip to content

Pr/OpenAI channel type support sora - #2055

Closed
feitianbubu wants to merge 4498 commits into
QuantumNous:mainfrom
feitianbubu:pr/openai-channel-type-support-sora
Closed

Pr/OpenAI channel type support sora#2055
feitianbubu wants to merge 4498 commits into
QuantumNous:mainfrom
feitianbubu:pr/openai-channel-type-support-sora

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Oct 16, 2025

Copy link
Copy Markdown
Member

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

image

Calcium-Ion and others added 30 commits September 29, 2025 16:45
解锁deepseek补全倍率;允许deepseek渠道获取模型
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
fix: Redirect address after successful tg binding
fix: sync third-party binding state in personal settings
…ENS/CUSTOM)

Replace the legacy boolean “DisplayInCurrencyEnabled” with an injected, type-safe
configuration `general_setting.quota_display_type`, and wire it through the
backend and frontend.

Backend
- Add `QuotaDisplayType` to `operation_setting.GeneralSetting` with injected
  registration via `config.GlobalConfig.Register("general_setting", ...)`.
  Helpers: `IsCurrencyDisplay()`, `IsCNYDisplay()`, `GetQuotaDisplayType()`.
- Expose `quota_display_type` in `/api/status` and keep legacy
  `display_in_currency` for backward compatibility.
- Logger: update `LogQuota` and `FormatQuota` to support USD/CNY/TOKENS. When
  CNY is selected, convert using `operation_setting.USDExchangeRate`.
- Controllers:
  - `billing`: compute subscription/usage amounts based on the selected type
    (USD: divide by `QuotaPerUnit`; CNY: USD→CNY; TOKENS: keep raw tokens).
  - `topup` / `topup_stripe`: treat inputs as “amount” for USD/CNY and as
    token-count for TOKENS; adjust min topup and pay money accordingly.
  - `misc`: include `quota_display_type` in status payload.
- Compatibility: in `model/option.UpdateOption`, map updates to
  `DisplayInCurrencyEnabled` → `general_setting.quota_display_type`
  (true→USD, false→TOKENS). Keep exporting the legacy key in `OptionMap`.

Frontend
- Settings: replace the “display in currency” switch with a Select
  (`general_setting.quota_display_type`) offering USD / CNY / Tokens.
  Provide fallback mapping from legacy `DisplayInCurrencyEnabled`.
- Persist `quota_display_type` to localStorage (keep `display_in_currency`
  for legacy components).
- Rendering helpers: base all quota/price rendering on `quota_display_type`;
  use `usd_exchange_rate` for CNY symbol/values.
- Pricing page: default view currency follows site display type (USD/CNY),
  while TOKENS mode still allows per-view currency toggling when needed.

Notes
- No database migrations required.
- Legacy clients remain functional via compatibility fields.
feat: support claude-sonnet-4-5-20250929
…debar-perf

fix: Optimize sidebar refresh to avoid redundant loading states
…ext-editing

feat: claude context editing
…claude

fix(relay): wrong URL for claude model in GCP Vertex AI
# Conflicts:
#	web/src/components/settings/PersonalSetting.jsx
#	web/src/i18n/locales/en.json
#	web/src/i18n/locales/zh.json
Calcium-Ion and others added 25 commits October 13, 2025 21:58
…generations

feat: 添加SiliconFlow图像生成接口自动转换支持
@coderabbitai

coderabbitai Bot commented Oct 16, 2025

Copy link
Copy Markdown
Contributor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 thread relay/relay_adaptor.go
Comment on lines +144 to +145
case constant.ChannelTypeOpenAI:
return &tasksora.TaskAdaptor{}

Copy link
Copy Markdown
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
Copy Markdown
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.