fix: 修正视频线性计费与在线测试模型筛选 #13

Merged
chengcheng merged 3 commits from codex/fix-linear-video-billing into main 2026-07-21 14:15:20 +08:00
Owner

背景

可灵视频以 5 秒为基础价时,旧逻辑使用向上取整,导致 6 秒从 200 跳到 400。目标分支还包含在线测试模型类型筛选修复,因此在本 PR 中一并明确。

改动

  • 视频费用改为按 duration / 5 线性计算,5 秒 200 时 6 秒为 240。
  • 保留 provider 返回的小数时长,V2 统一使用定点精度并在最终乘积后舍入。
  • 新增迁移,将现存视频规则的旧 ceil(duration_seconds / 5) 元数据改为线性公式。
  • 修正在线测试模型类型筛选,避免将 image_to_video 误判为图像模型,并增加回归测试。

影响与风险

  • 视频计费的 quantitydurationUnitCount 允许小数。
  • 迁移仅替换视频规则中精确匹配的旧公式片段,不修改历史迁移。
  • HTTP 契约未变化,无需更新 OpenAPI 产物。

验证

  • go vet ./...
  • pnpm lint
  • pnpm test
  • pnpm build
  • ./tests/ci/migrations-test.sh
  • git diff --check origin/main...HEAD

合并前必须等待精确状态 ci / verify (pull_request) 成功。

## 背景 可灵视频以 5 秒为基础价时,旧逻辑使用向上取整,导致 6 秒从 200 跳到 400。目标分支还包含在线测试模型类型筛选修复,因此在本 PR 中一并明确。 ## 改动 - 视频费用改为按 `duration / 5` 线性计算,5 秒 200 时 6 秒为 240。 - 保留 provider 返回的小数时长,V2 统一使用定点精度并在最终乘积后舍入。 - 新增迁移,将现存视频规则的旧 `ceil(duration_seconds / 5)` 元数据改为线性公式。 - 修正在线测试模型类型筛选,避免将 `image_to_video` 误判为图像模型,并增加回归测试。 ## 影响与风险 - 视频计费的 `quantity` 与 `durationUnitCount` 允许小数。 - 迁移仅替换视频规则中精确匹配的旧公式片段,不修改历史迁移。 - HTTP 契约未变化,无需更新 OpenAPI 产物。 ## 验证 - `go vet ./...` - `pnpm lint` - `pnpm test` - `pnpm build` - `./tests/ci/migrations-test.sh` - `git diff --check origin/main...HEAD` 合并前必须等待精确状态 `ci / verify (pull_request)` 成功。
chengcheng added 3 commits 2026-07-21 13:42:41 +08:00
移除可能将 image_to_video 误判为图像模型的子串回退,在没有匹配模型时显示空状态。

新增图像生成、图像编辑和视频模式回归测试。验证通过:前端 94 项测试、类型检查、lint 和生产构建。
将五秒基础价按 duration / 5 比例结算,保留 provider 返回的小数时长,避免六秒视频被按两个完整单位收费。

影响:所有使用 5s 视频基础价的模型,quantity 与 durationUnitCount 允许小数。新增迁移同步现存规则的旧 ceil 公式元数据。

验证:go vet ./...;pnpm lint;pnpm test;pnpm build;./tests/ci/migrations-test.sh
chore(git): 合并视频时长线性计费修复
ci / verify (pull_request) Successful in 13m41s
142dcc7932
chengcheng merged commit e280c0875c into main 2026-07-21 14:15:20 +08:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BCAI/easyai-ai-gateway#13