feat(channel): add Yike video generation and credit balance - #6736
feat(channel): add Yike video generation and credit balance#6736lelinhomafx4021-creator wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
🚧 Files skipped from review as they are similar to previous changes (10)
WalkthroughThis change adds Yike as a native video-generation channel. It implements signed RPC submission and polling, credit retrieval, credential validation, model discovery, retry channel reuse, sensitive-data sanitization, frontend configuration, localized labels, and usage documentation. ChangesYike task adaptor and signing
Channel registration and relay wiring
Credit retrieval and balance responses
Polling, proxy, and error sanitization
Frontend channel configuration and credit display
Yike channel documentation
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/features/channels/components/dialogs/balance-query-dialog.tsx (1)
48-48: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPass the app locale to
formatYikeCreditsfor consistent number formatting.
formatBalancecallsformatYikeCredits(bal, t('Credits'))without alocale.channels-columns.tsxpassestoIntlLocale(i18n.resolvedLanguage || i18n.language)for the same helper. Without the same locale, this dialog formats Yike credit numbers using the environment default locale instead of the user's selected app language. This creates inconsistent number formatting between the two places Yike balances render.Destructure
i18nfromuseTranslation()and compute the same locale here.🌐 Proposed fix to pass the resolved locale
- const { t } = useTranslation() + const { t, i18n } = useTranslation() const { currentRow, setCurrentRow } = useChannels() const queryClient = useQueryClient() const [isQuerying, setIsQuerying] = useState(false) @@ const isCodex = currentRow?.type === 57 const isYike = isYikeChannel(currentRow?.type) + const locale = toIntlLocale(i18n.resolvedLanguage || i18n.language) @@ const formatBalance = (bal: number) => isYike - ? formatYikeCredits(bal, t('Credits')) + ? formatYikeCredits(bal, t('Credits'), locale) : formatCurrencyFromUSD(bal, {Import
toIntlLocalefrom whereverchannels-columns.tsximports it.Also applies to: 132-139
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/features/channels/components/dialogs/balance-query-dialog.tsx` at line 48, Update the useTranslation() destructuring in the balance query dialog to include i18n, import and use toIntlLocale as channels-columns.tsx does, and compute the resolved app locale from i18n.resolvedLanguage || i18n.language. Pass that locale to formatYikeCredits within formatBalance, preserving the existing Credits label and balance formatting behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/features/channels/lib/channel-type-config.ts`:
- Around line 171-182: Replace the raw hints.baseUrl string in the
CHANNEL_TYPE_YIKE configuration with a translation key, following the existing
locale-key pattern used by similar channel URL hints. Add the matching key and
translated value to every locale file so the hint is localized before rendering.
In `@web/src/features/channels/lib/yike-balance.ts`:
- Around line 25-36: Update formatYikeCredits to return '-' when balance is
null, undefined, or NaN, matching the guard used by formatCurrencyFromUSD;
otherwise preserve the existing Intl.NumberFormat formatting and unit-label
output.
In `@web/src/i18n/locales/ja.json`:
- Line 1679: Update the Japanese translation value for the
AccessKeyId|AccessKeySecret guidance to replace “順番に選択されます” with the existing
“順次ポーリング” terminology, while preserving the rest of the translation unchanged.
---
Outside diff comments:
In `@web/src/features/channels/components/dialogs/balance-query-dialog.tsx`:
- Line 48: Update the useTranslation() destructuring in the balance query dialog
to include i18n, import and use toIntlLocale as channels-columns.tsx does, and
compute the resolved app locale from i18n.resolvedLanguage || i18n.language.
Pass that locale to formatYikeCredits within formatBalance, preserving the
existing Credits label and balance formatting behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 74666538-e729-404f-a629-77c74753d655
📒 Files selected for processing (44)
common/endpoint_type.goconstant/channel.gocontroller/channel-billing.gocontroller/channel-test.gocontroller/channel.gocontroller/channel_billing_yike_test.gocontroller/channel_upstream_update.gocontroller/model.gocontroller/relay.gocontroller/video_proxy.godocs/channel/yike.mdmodel/task.gorelay/channel/adapter.gorelay/channel/api_request.gorelay/channel/task/yike/adaptor.gorelay/channel/task/yike/adaptor_test.gorelay/channel/task/yike/signer.gorelay/channel/task/yike/signer_test.gorelay/common/relay_utils.gorelay/common/relay_utils_test.gorelay/relay_adaptor.gorelay/relay_task.goservice/task_polling.goservice/task_polling_test.goweb/src/assets/custom/icon-yike.tsxweb/src/features/channels/components/channels-columns.tsxweb/src/features/channels/components/dialogs/balance-query-dialog.tsxweb/src/features/channels/components/drawers/channel-mutate-drawer.tsxweb/src/features/channels/constants.tsweb/src/features/channels/lib/__tests__/yike-balance.test.tsweb/src/features/channels/lib/channel-actions.tsweb/src/features/channels/lib/channel-type-config.tsweb/src/features/channels/lib/channel-utils.tsweb/src/features/channels/lib/index.tsweb/src/features/channels/lib/yike-balance.tsweb/src/features/channels/types.tsweb/src/i18n/locales/en.jsonweb/src/i18n/locales/fr.jsonweb/src/i18n/locales/ja.jsonweb/src/i18n/locales/ru.jsonweb/src/i18n/locales/vi.jsonweb/src/i18n/locales/zh-TW.jsonweb/src/i18n/locales/zh.jsonweb/src/lib/lobe-icon.tsx
| [CHANNEL_TYPE_YIKE]: { | ||
| id: CHANNEL_TYPE_YIKE, | ||
| name: CHANNEL_TYPES[CHANNEL_TYPE_YIKE], | ||
| icon: 'Yike', | ||
| defaultBaseUrl: 'https://yike.cn-shanghai.aliyuncs.com', | ||
| hints: { | ||
| baseUrl: | ||
| 'Shanghai: https://yike.cn-shanghai.aliyuncs.com; Singapore: https://yike.ap-southeast-1.aliyuncs.com; HTTPS only', | ||
| key: TYPE_TO_KEY_PROMPT[CHANNEL_TYPE_YIKE], | ||
| models: 'Wonder-Pro,Wonder-Standard,happyhorse-1.1,happyhorse-1.0,wan2.7', | ||
| }, | ||
| }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check how channel hints (including baseUrl) are rendered, and whether the
# Yike baseUrl hint string has translation entries across all locale files.
# Test 1: Find where hints.baseUrl (or hints in general) is consumed/translated.
rg -n -C4 'hints\.(baseUrl|key|models)' web/src/features/channels
# Test 2: Check whether the Yike baseUrl hint string exists in each locale file.
rg -n 'yike.cn-shanghai' web/src/i18n/locales/*.jsonRepository: QuantumNous/new-api
Length of output: 157
🏁 Script executed:
#!/bin/bash
set -u
printf 'Tracked files around channels:/i18n/locales: \n'
git ls-files | rg '(^|/)channel-type-config\.ts$|web/src/i18n/locales/.*\.json$|web/src/features/channels' | head -200
printf '\nchannel-type-config outline/size:\n'
wc -l web/src/features/channels/lib/channel-type-config.ts 2>/dev/null || true
ast-grep outline web/src/features/channels/lib/channel-type-config.ts --view compact 2>/dev/null | head -120 || true
printf '\nSearch for hints consumption (broader regex):\n'
rg -n -C3 'hints\s*\.|hints\[' web/src/features/channels web/src/features 2>/dev/null | head -200 || true
printf '\nSearch exact Yike baseUrl hint and locale mentions:\n'
rg -n 'yike\.cn-shanghai|yike\.ap-southeast-1|https://yike\.|Wonder-Pro,Wonder-Standard' web/src/i18n/locales web/src/features/channels 2>/dev/null || trueRepository: QuantumNous/new-api
Length of output: 4897
🏁 Script executed:
#!/bin/bash
set -u
printf 'Relevant snippets from web/src/features/channels/lib/channel-type-config.ts \n'
sed -n '140,190p' web/src/features/channels/lib/channel-type-config.ts 2>/dev/null || true
printf '\nChannel type and prompt references around CHANNEL_TYPE_YIKE \n'
rg -n -C3 'CHANNEL_TYPE_YIKE|TYPE_TO_KEY_PROMPT|baseUrl:\s*' web/src/features/channels/web/src -g '*.ts' -g '*.tsx' 2>/dev/null | head -240 || trueRepository: QuantumNous/new-api
Length of output: 1611
🏁 Script executed:
#!/bin/bash
set -u
printf 'Hint usages in channels feature and parent files:\n'
rg -n -C5 'hints|getTypeConfig|getChannelTypeConfig|ChannelTypeConfig|TYPE_TO_KEY_PROMPT|baseUrl' \
web/src/features/channels web/src/features 2>/dev/null | head -300 || true
printf '\nTranslation keys containing URL hints/arccn/yike:\n'
python3 - <<'PY'
import json, pathlib
for p in sorted(pathlib.Path('web/src/i18n/locales').glob('*.json')):
try:
data=json.loads(p.read_text())
except:
continue
hits=[]
def walk(o,path=''):
if isinstance(o, str) and ('url' in o.lower() or 'baseUrl' in o.lower() or 'shanghai' in o.lower() or 'singapore' in o.lower()):
hits.append((path,o[:180]))
elif isinstance(o, dict):
for k,v in o.items():
walk(v,path+'.'+str(k))
elif isinstance(o, list):
for i,v in enumerate(o):
walk(v,path+'['+str(i)+']')
walk(data)
print(p)
for path,o in hits[:40]:
print(f' {path}: {o}')
PYRepository: QuantumNous/new-api
Length of output: 50375
Add a translation key for the Yike baseUrl hint.
hints.baseUrl is a raw English string for this channel, while similar URL hints already use locale entries. Add matching keys for all locale files and update this config to reference the translation key before the hint is rendered.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/src/features/channels/lib/channel-type-config.ts` around lines 171 - 182,
Replace the raw hints.baseUrl string in the CHANNEL_TYPE_YIKE configuration with
a translation key, following the existing locale-key pattern used by similar
channel URL hints. Add the matching key and translated value to every locale
file so the hint is localized before rendering.
Add signed Yike video task submission, polling, model discovery, and native account-credit refresh. Yike balances are explicitly returned and displayed as credits instead of USD.
4401336 to
b93df6a
Compare
补充实现说明Yike 使用独立的任务型 OpenAPI,不兼容现有 DashScope/OpenAI 上游协议。ACS3 签名、请求转换和 Provider 专用逻辑集中在 当前支持 Additional implementation contextYike uses a standalone task-based OpenAPI and is not compatible with the existing DashScope/OpenAI upstream protocol. ACS3 signing, request conversion, and provider-specific logic are isolated under Supported models include |
|
@seefs001 Could you please review this PR? Thank you! |
Important
📝 变更描述 / Description
新增万镜一刻(Yike)视频生成渠道,接入的是独立的 Yike OpenAPI,不复用或修改现有阿里百炼/DashScope 视频适配器。
请求进入后,适配器使用渠道中配置的阿里云 AK/SK 完成 ACS3 签名,提交并轮询视频任务,最终返回上游任务数据和 Yike 官方临时 OSS 地址。同时补充渠道配置、模型获取、参数校验、积分查询、前端标识和接入文档。
为避免渠道测试产生视频费用,渠道测试和积分刷新只调用只读接口;任务轮询继续使用任务提交时选中的密钥。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
wan2.7真实任务验证:任务状态为
SUCCESS,进度为100%,providerdata非空,result_url为 Yike 官方临时 OSS 地址。video/mp4,文件头为ftyp。Summary by CodeRabbit
New Features
Security
Documentation