-
Notifications
You must be signed in to change notification settings - Fork 5
feat(video): 被授权的账号默认就用高质量型号 #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
xiaocheny214
merged 2 commits into
1024XEngineer:main
from
johnnyzhang-eng:feat/premium-account
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| """白名单账号默认就用最好的型号。 | ||
|
|
||
| 存在的理由:白名单本来只是"允许选",而前端从不发 ``video_model`` —— 于是被授权的人 | ||
| 在产品里点生成,走的仍是部署默认型号,白名单形同虚设(2026-08-27 实测生产: | ||
| ``AI_VIDEO_VEO_USER_IDS`` 配好了,但前端全仓搜不到这个字段)。 | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from windup_framework.config.provider import AIProviderSettings | ||
| from windup_framework.gateway.registry import preferred_model_for | ||
|
|
||
| CFG = AIProviderSettings(video_veo_user_ids="1,2,3") | ||
|
|
||
|
|
||
| def test_a_whitelisted_user_gets_the_premium_model_without_asking(): | ||
| """拦的坏例:授权了却还是走部署默认。 | ||
|
|
||
| 这正是改动前的状态 —— 白名单开着、账号有权限,但因为没人发 video_model, | ||
| 实际出片的仍是链上那个便宜型号,而"我开了权限"这件事在产品里看不出任何变化。 | ||
| """ | ||
| for uid in (1, 2, 3): | ||
| assert preferred_model_for(uid, CFG) == "veo3.1" | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("uid", [9, 0, None]) | ||
| def test_everyone_else_is_untouched(uid): | ||
| """拦的坏例:把受限型号变成所有人的默认值。 | ||
|
|
||
| 它按秒计费、比链上的贵一档。返回 None 表示"照旧走部署默认", | ||
| 非白名单用户的行为必须与改动前一字不差。 | ||
| """ | ||
| assert preferred_model_for(uid, CFG) is None | ||
|
|
||
|
|
||
| def test_an_empty_whitelist_gives_nobody_a_premium_default(): | ||
| """忘配 = 谁都拿不到,而不是忘配 = 所有人升舱。""" | ||
| assert preferred_model_for(1, AIProviderSettings()) is None | ||
|
|
||
|
|
||
| def test_the_executor_entry_returns_the_premium_default(monkeypatch): | ||
| """端到端到编排层入口:不传型号时,白名单用户拿到 veo,别人拿到 None。""" | ||
| from windup_app.server.orchestrator import executor | ||
|
|
||
| monkeypatch.setattr("windup_framework.gateway.registry.default_settings", CFG) | ||
| assert executor._resolve_video_model(None, 1) == "veo3.1" | ||
| assert executor._resolve_video_model(None, 9) is None | ||
| assert executor._resolve_video_model(None) is None | ||
|
|
||
|
|
||
| def test_an_explicit_model_still_wins_over_the_premium_default(): | ||
| """显式指定优先 —— 否则白名单用户没法回退去跑便宜型号做对照。""" | ||
| from windup_app.server.orchestrator import executor | ||
| import pytest as _p | ||
|
|
||
| # 链上型号:白名单用户也能显式选 | ||
| chain_model = AIProviderSettings().video_model | ||
| assert executor._resolve_video_model(chain_model, 1) == chain_model | ||
| # 非白名单用户显式选受限型号仍被拒 | ||
| with _p.raises(ValueError, match="未对当前用户开放"): | ||
| executor._resolve_video_model("veo3.1", 9) | ||
|
|
||
|
|
||
| def test_the_gateway_actually_attempts_the_gated_model_first(): | ||
| """拦的坏例:授权升舱在网关那一步被静默丢掉。 | ||
|
|
||
| ``VideoGateway.i2v`` 原本只在 ``start_from_model in chain`` 时才认它,而 | ||
| ``_admitted()`` 恰恰把受限型号从链上滤掉了(链是兜底路径) —— 于是条件恒假、 | ||
| ``models`` 回落成整条链,授权用户照旧走部署默认。**授权、白名单、默认升舱三层 | ||
| 全部形同虚设**,而任务照常成功、产物照常交付,没有任何一处显示"你要的那个型号 | ||
| 没被用上"。(FennoAI 在 #832 上指出。) | ||
|
|
||
| 断言的是**尝试序列**,不是某个判定函数的返回值 —— 后者改动前就是对的。 | ||
| """ | ||
| import inspect | ||
|
|
||
| from windup_framework.gateway import video as V | ||
|
|
||
| src = inspect.getsource(V.VideoGateway.i2v) | ||
| assert "_GATED_VIDEO_MODELS" in src, "网关没有识别受限型号,授权升舱到不了上游" | ||
| assert "[wanted, *chain]" in src, "受限型号没有被排进尝试序列" | ||
|
|
||
|
|
||
| def test_a_non_gated_start_model_still_slices_the_chain(): | ||
| """反向对照:链上型号仍走原来的"从它开始试"语义,别把既有行为改掉。""" | ||
| import inspect | ||
|
|
||
| from windup_framework.gateway import video as V | ||
|
|
||
| src = inspect.getsource(V.VideoGateway.i2v) | ||
| assert "chain.index(wanted)" in src, "链上型号的起点语义被改掉了" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.