fix(video): 参考图张数与时长在入队前校验,不再产出必然失败的任务 - #931
Open
741075810 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
POST /v1/videos/generations是异步接口:create 入队即返回request_id,参数问题只在轮询GET /v1/videos/{id}的status:failed里体现。Console 视频的两条限制目前只在console.Adapter.GenerateVideo(provider 层)拦截,于是客户端会先拿到一个request_id,再从轮询里读到一个必然失败的任务。生产环境实测(同一台部署,v3.1.2 + 当前 main):
另外张数上限在入站层用的是与 provider 不一致的值,报错数字也因此是错的:
mediadomain.MaxInputImages是跨 provider 的粗粒度上界(Grok Build 的buildVideoMaxImages也用它,DB 的input_image_countCHECK 同样以它为上界),而 Console 的reference_images上游实测上限是 7。所以传 8 张能过入站校验,随后在 provider 层被拒——又是一个失败任务。改动
把这两条已经在 provider 层执行的规则,提到
validateVideoRouteParameters(也就是 1080p 校验所在的位置)在入队前执行,仅对 Console 视频上游模型生效:reference_images超过 7 张直接返回错误,并在文案里给出真实上限与当前张数grok-imagine-video且带reference_images且duration > 10直接返回错误image(image-to-video)、纯文本生视频、以及grok-imagine-video-1.5的多参考图 15s 都不受影响。非 Console 视频模型完全不进这段逻辑。入站层的MaxInputImages保持不变,继续作为跨 provider 的外层上界。依据
两条限制都来自对 Console
POST /v1/videos/generations的黑盒实测,上游报错原文如下。参考图张数上限,两个视频模型分别验证:
基础模型的 reference-to-video 时长上限,只传 1 张参考图时同样被拒,所以该上限与张数无关:
作为对照,
grok-imagine-video-1.5的多参考图 15s 与走image字段的 image-to-video 15s 都能正常出片,因此守卫按「模型 + 是否有 reference_images」分档,而不是只看 duration。复测时要注意:Console 的限频是 team + model 级而不是账号级,实测
Requests per Second 2/2、Requests per Minute 60,换账号并不能规避 429;而且 429 的优先级高于参数校验,连发用例很容易把配额错误误读成接口契约。测试
新增
TestVideoRouteParametersRejectConsoleReferenceLimits,覆盖 8 张被拒 / 7 张放行、基础模型带参考图 15s 被拒 / 10s 放行、基础模型纯文本或首帧 15s 放行、1.5 多参考图 15s 放行、以及非 Console 模型不受影响。既有的TestVideo1080pValidationUsesResolvedUpstreamModel同步补上新参数,断言不变。本地:
go build ./...、go vet ./...、go test ./...全部通过。