refactor(providers): 把视频协议提取为显式接缝 - #562
Merged
johnnyzhang-eng merged 1 commit intoAug 24, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
已审阅固定范围 17b25a723410244d9f0a68209d3c946ca0698b56...0d6a0ba2dc7caae19124a2961ce8ac1ea96ea366 的完整改动,重点核对了视频协议提取、AdapterResult 字段契约、轮询错误/计费状态、鉴权头与图像面共享的边缘指纹逻辑。没有发现满足报告门槛的新增正确性、可靠性或安全问题。
验证:python3 -m compileall 与 git diff --check 通过;当前环境未安装 pytest/uv,因此未能执行运行时测试。
Contributor
Author
xyh202131
previously approved these changes
Aug 24, 2026
请求构造与响应解析原先写死在 sufy.py 的条件分支里,路径、鉴权与轮询协议三样都由 adapter 自己拼。新增一个协议面因此只能继续往同一个文件里加分支 —— 上一次那样做的 412 行最终被整体删除,理由是接不进产品链路。 协议层只产出纯数据:build_submit/parse_submit/build_poll/parse_poll/build_fetch 都是纯 函数,不发请求、不重试、不休眠;轮询节奏与 52x 重发仍归 adapter。鉴权头由协议层产出 而不由厂商层统一注入,因为 Key 与 Bearer 写反时的响应与"模型不存在"难以区分。 edge_fingerprint 迁到 gateway.classify:视频面与图像面都要用,留在任一 provider 里会造成 循环导入。AdapterResult 加 result_url —— OpenAI 面的产物地址在轮询响应里,协议层需要 一个交回它的位置,否则只能另造一个平行的结果类型。 OpenAI 面行为不变,由既有 sufy 视频用例约束;新增 12 条脱网单测覆盖两层之间的契约 (未完成时 error_type 为 None)、鉴权头、以及 image_list 与 input_reference 的字段选择。
Contributor
Author
johnnyzhang-eng
force-pushed
the
refactor/video-job-protocol
branch
from
August 24, 2026 04:11
0d6a0ba to
b7bd839
Compare
xyh202131
approved these changes
Aug 24, 2026
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.
Closes #561
按 #332 第 6.2 节的接口实现,本 PR 只做提取,不接新协议面。
新增
providers/protocol/:JobProtocol接口(build_submit/parse_submit/build_poll/parse_poll/build_fetch)与 OpenAI 面实现。协议层只产出纯数据,不发请求、不重试、不休眠;轮询节奏、52x 重发与下载仍归 adapter。鉴权头由协议层产出而不由厂商层统一注入——Key 与 Bearer 写反时的响应与「模型不存在」难以区分。两处对 #332 原文的偏离,需要评审确认:
parse_poll多收一个job_id参数。原文签名是parse_poll(resp) -> AdapterResult,但错误路径要把单号带回去,否则重试会新开一单、二次计费。AdapterResult增加可选字段result_url。OpenAI 面的产物地址在轮询响应里,协议层需要一个交回它的位置;不加就得另造一个平行的结果类型,而 Proposal: 接入 Fal 队列协议面,并把协议表达为显式接缝 #332 明确要求沿用同一个。edge_fingerprint与_DIAGNOSTIC_HEADERS迁到gateway.classify:视频面与图像面都要用,留在任一 provider 里会造成循环导入;异常路径的 edge 本来就由classify_exception产出,同一处。行为不变由既有 sufy 视频用例约束。新增 12 条脱网单测覆盖两层之间的契约、鉴权头、以及字段选择。三个 mutation 实测全部转红:
Bearer→Keyerror_typeimage_list带上data:前缀还原后文件 sha256 与改动前一致。
本分支验证:
ruff check .通过、lint-imports2 kept 0 broken、export_openapi后openapi.json无漂移、pytest -q1341 passed / 14 skipped(较基线 +12 条新用例)。