Pr/OpenAI channel type support sora - #2055
Conversation
解锁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
add submodel.ai
fix : fix submodel adapter
…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
fix: claude beta=true
…ext-editing feat: claude context editing
Alpha -> main
…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
…generations feat: 添加SiliconFlow图像生成接口自动转换支持
…pe_log feat: endpoint type log
… improve error handling
WalkthroughUpdates 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
Metadatafield already usesjson:"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.
| case constant.ChannelTypeOpenAI: | ||
| return &tasksora.TaskAdaptor{} |
There was a problem hiding this comment.
🧩 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:
- Does the
Initmethod properly set theChannelTypefield fromRelayInfo? - Are there any conditional branches in TaskAdaptor that assume only Sora channel type?
- 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 -20Length 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.
|
现在的代码已经有这个OpenAI渠道自带sora视频生成的内容了 |
OpeanAI渠道类型支持sora视频生成

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