Skip to content

feat(channel): add Yike video generation and credit balance - #6736

Open
lelinhomafx4021-creator wants to merge 3 commits into
QuantumNous:mainfrom
lelinhomafx4021-creator:pr/yike-channel
Open

feat(channel): add Yike video generation and credit balance#6736
lelinhomafx4021-creator wants to merge 3 commits into
QuantumNous:mainfrom
lelinhomafx4021-creator:pr/yike-channel

Conversation

@lelinhomafx4021-creator

@lelinhomafx4021-creator lelinhomafx4021-creator commented Aug 9, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

新增万镜一刻(Yike)视频生成渠道,接入的是独立的 Yike OpenAPI,不复用或修改现有阿里百炼/DashScope 视频适配器。

请求进入后,适配器使用渠道中配置的阿里云 AK/SK 完成 ACS3 签名,提交并轮询视频任务,最终返回上游任务数据和 Yike 官方临时 OSS 地址。同时补充渠道配置、模型获取、参数校验、积分查询、前端标识和接入文档。

为避免渠道测试产生视频费用,渠道测试和积分刷新只调用只读接口;任务轮询继续使用任务提交时选中的密钥。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

  • Yike 适配器、ACS3 签名、请求转换、任务轮询和积分查询相关 Go 测试通过。
  • 前端类型检查、Yike 积分展示测试及生产构建通过。
  • 使用 MySQL 完成 wan2.7
    真实任务验证:任务状态为 SUCCESS,进度为 100%,provider data 非空,result_url 为 Yike 官方临时 OSS 地址。
  • 视频内容接口返回 HTTP 200、video/mp4,文件头为 ftyp
Snipaste_2026-08-09_23-02-59 Snipaste_2026-08-09_23-03-12 Snipaste_2026-08-09_23-07-10 Snipaste_2026-08-09_23-08-09 Snipaste_2026-08-09_23-15-08

Summary by CodeRabbit

  • New Features

    • Added Yike as a supported video-generation provider.
    • Supports text-to-video, image-to-video, first/last-frame, and reference-video workflows.
    • Added credential validation, model discovery, task processing, polling, and account-credit checks.
    • Added Yike channel configuration, icon, credential guidance, localized labels, and credit-based balance displays.
  • Security

    • Improved protection of sensitive credentials and request details in logs and video responses.
  • Documentation

    • Added setup and usage documentation covering configuration, supported options, and examples.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ca9507f9-78a8-4651-ad8f-8c480e3f44ae

📥 Commits

Reviewing files that changed from the base of the PR and between 4401336 and 241434e.

📒 Files selected for processing (11)
  • web/src/features/channels/components/dialogs/balance-query-dialog.tsx
  • web/src/features/channels/lib/__tests__/yike-balance.test.ts
  • web/src/features/channels/lib/channel-type-config.ts
  • web/src/features/channels/lib/yike-balance.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (10)
  • web/src/i18n/locales/ja.json
  • web/src/features/channels/lib/yike-balance.ts
  • web/src/features/channels/lib/tests/yike-balance.test.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/ru.json
  • web/src/features/channels/lib/channel-type-config.ts
  • web/src/i18n/locales/vi.json
  • web/src/features/channels/components/dialogs/balance-query-dialog.tsx
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/zh-TW.json

Walkthrough

This 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.

Changes

Yike task adaptor and signing

Layer / File(s) Summary
Task conversion, signing, polling, and validation
relay/channel/task/yike/*
Adds Yike RPC signing, video request conversion, media validation, task polling, credit retrieval, credential checks, output parsing, and comprehensive tests.

Channel registration and relay wiring

Layer / File(s) Summary
Channel and relay integration
common/endpoint_type.go, constant/channel.go, relay/channel/adapter.go, relay/relay_adaptor.go, relay/relay_task.go, controller/*, model/task.go
Registers channel type 61, connects the Yike task adaptor, validates credentials and endpoints, discovers models, persists task credentials, validates mapped models, and reuses Yike channels during retries.

Credit retrieval and balance responses

Layer / File(s) Summary
Credit balance handling
controller/channel-billing.go, controller/channel_billing_yike_test.go
Retrieves Yike account credits and returns Yike balances with the credits unit.

Polling, proxy, and error sanitization

Layer / File(s) Summary
Sensitive-data protection
relay/common/*, relay/channel/api_request.go, controller/video_proxy.go, service/task_polling*
Sanitizes Yike URLs, errors, logs, polling responses, and proxy failures while preserving public output data.

Frontend channel configuration and credit display

Layer / File(s) Summary
Channel setup and balance presentation
web/src/features/channels/*, web/src/assets/custom/icon-yike.tsx, web/src/lib/lobe-icon.tsx, web/src/i18n/locales/*
Adds Yike credentials, models, iconography, localized labels, input guidance, credit formatting, and credit balance displays.

Yike channel documentation

Layer / File(s) Summary
Configuration and API documentation
docs/channel/yike.md
Documents Yike configuration, credentials, task workflows, supported parameters, media rules, balance queries, and verification commands.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: calcium-ion

Poem

A rabbit signs requests beneath the moon,
Polls each video task to its tune.
Credits sparkle, secrets hide,
Yike hops safely side by side.
New icons bloom in every view.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding Yike video generation and credit balance support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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: 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 win

Pass the app locale to formatYikeCredits for consistent number formatting.

formatBalance calls formatYikeCredits(bal, t('Credits')) without a locale. channels-columns.tsx passes toIntlLocale(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 i18n from useTranslation() 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 toIntlLocale from wherever channels-columns.tsx imports 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

📥 Commits

Reviewing files that changed from the base of the PR and between 823e263 and 4401336.

📒 Files selected for processing (44)
  • common/endpoint_type.go
  • constant/channel.go
  • controller/channel-billing.go
  • controller/channel-test.go
  • controller/channel.go
  • controller/channel_billing_yike_test.go
  • controller/channel_upstream_update.go
  • controller/model.go
  • controller/relay.go
  • controller/video_proxy.go
  • docs/channel/yike.md
  • model/task.go
  • relay/channel/adapter.go
  • relay/channel/api_request.go
  • relay/channel/task/yike/adaptor.go
  • relay/channel/task/yike/adaptor_test.go
  • relay/channel/task/yike/signer.go
  • relay/channel/task/yike/signer_test.go
  • relay/common/relay_utils.go
  • relay/common/relay_utils_test.go
  • relay/relay_adaptor.go
  • relay/relay_task.go
  • service/task_polling.go
  • service/task_polling_test.go
  • web/src/assets/custom/icon-yike.tsx
  • web/src/features/channels/components/channels-columns.tsx
  • web/src/features/channels/components/dialogs/balance-query-dialog.tsx
  • web/src/features/channels/components/drawers/channel-mutate-drawer.tsx
  • web/src/features/channels/constants.ts
  • web/src/features/channels/lib/__tests__/yike-balance.test.ts
  • web/src/features/channels/lib/channel-actions.ts
  • web/src/features/channels/lib/channel-type-config.ts
  • web/src/features/channels/lib/channel-utils.ts
  • web/src/features/channels/lib/index.ts
  • web/src/features/channels/lib/yike-balance.ts
  • web/src/features/channels/types.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json
  • web/src/lib/lobe-icon.tsx

Comment on lines +171 to +182
[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',
},
},

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.

📐 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/*.json

Repository: 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 || true

Repository: 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 || true

Repository: 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}')
PY

Repository: 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.

Comment thread web/src/features/channels/lib/yike-balance.ts
Comment thread web/src/i18n/locales/ja.json Outdated
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.
@lelinhomafx4021-creator

Copy link
Copy Markdown
Author

补充实现说明

Yike 使用独立的任务型 OpenAPI,不兼容现有 DashScope/OpenAI 上游协议。ACS3 签名、请求转换和 Provider 专用逻辑集中在 relay/channel/task/yike;共享代码改动用于渠道注册、视频任务路由与轮询、提交密钥持久化、模型发现、只读渠道/积分检查、前端展示以及签名 URL 的敏感信息保护。

当前支持 Wonder-ProWonder-Standardhappyhorse-1.0happyhorse-1.1wan2.7。其中已使用 MySQL 和真实 wan2.7 任务完成端到端验证:任务状态从 queuedIN_PROGRESSSUCCESS,最终返回 Yike 官方临时 OSS 地址,视频内容接口返回 video/mp4

Additional implementation context

Yike 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 relay/channel/task/yike. Shared integration points cover channel registration, video task routing and polling, selected-credential persistence, model discovery, read-only channel/credit checks, UI display, and signed-URL sanitization.

Supported models include Wonder-Pro, Wonder-Standard, happyhorse-1.0, happyhorse-1.1, and wan2.7. A MySQL-backed end-to-end test was completed with a real wan2.7 task: the task progressed from queued to IN_PROGRESS and SUCCESS, returned an official temporary Yike OSS URL, and the content endpoint responded with video/mp4.

@lelinhomafx4021-creator

Copy link
Copy Markdown
Author

@seefs001 Could you please review this PR? Thank you!

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.

1 participant