Agnes 免费/限时免费标注 + 免费标签间距对齐(老板 2026-09-24)
老板两件事:
1) Agnes 的模型也要标免费或限时免费 —— 之前只有 OpenCode 的 space-bunny-free 有标注;
2) 免费标签跟模型名的间隔不一样,优化。
免费标注:
- 口径(照官方措辞,按 bullet 切块判定,不关键词泛扫):
· OpenCode 价格表 Input/Output = Free(原逻辑)
· Agnes 定价页「### 当前优惠」:当前(均)免费 → 免费;当前限时免费 → 限时免费
坑:Agnes 视频 agnes-video-2.5 那条 bullet 写着「输入图片前 5 张免费」——
那是计费公式的免费额度、不是模型免费,所以只认严格措辞「当前免费 / 当前均免费 /
均免费 / 限时免费」,且只认反引号里的完整 id(agnes-video-2.5 是
agnes-video-2.5-flash 的子串,字符串包含会串味)。
- 配置:free: true(免费)+ 新增 free_limited: true(限时免费)。
落盘 7 条:3.0-flash / 2.5-flash / image-2.0-flash / image-2.1-flash /
image-2.5-flash / video-v2.0 = 免费;video-2.5-flash = 限时免费。
- scripts/sync_models.py:新增 _agnes_free_map() / _set_agnes_free(),免费标注纳入
漂移比对 + --apply 落盘(官方改口径 → 整行撤掉标注),回读校验新增 Agnes 免费位检查;
新增模型块也会带上标注。
- 后端:ModelInfo.free_limited + /v1/models 带出 free_limited(别名随目标继承)。
- 前端:标签文案 免费 / 限时免费(中英各 +2 键,i18n 755/755 对称),提示语同步更新
(原文案只提 OpenCode Go 计划,已不准确)。
间距:
- 根因:.st-row 是 flex(gap:8px),.name-free 又加 margin-left:6px → 标签左侧 8+6=14px、
右侧 8px,与其它行「模型名 → 供应商名」的 8px 节奏不一致。
- 修法:.st-row .name-free { margin-left: 0 }(表格单元格是行内排布、无 flex gap,
那边保留 6px)。同源最小页实测:修前 14/8,修后 8/8。
测试:新增 test_agnes_free_map_rules、test_agnes_free_apply_and_revoke_round_trip
(含 撤标注/限时→免费/幂等/相邻手写注释不被碰);195 passed / 0 failed。
This commit is contained in:
1 parent
e3e8cac54f
commit
aabd473b33
10 files changed
+312
-12
No files matched your search
@@ -5101,6 +5101,98 @@ def test_sync_plan_is_empty_drills_into_provider_buckets():
|
||||
assert sm.plan_is_empty({**empty, "free_set": {"m": True}}) is False
|
||||
|
||||
|
||||
def test_agnes_free_map_rules():
|
||||
"""Agnes 免费标注解析(2026-09-24 老板要求 Agnes 也标免费 / 限时免费)。
|
||||
|
||||
只用文档里的**严格措辞**判定,且必须按 bullet/段落切块 + 只认反引号里的完整 id:
|
||||
· 「当前均免费」「当前免费」→ 免费;「限时免费」→ 限时免费
|
||||
· 「输入图片前 5 张免费」这种计费公式附注 **不算** 模型免费(视频 2.5 就是这样)
|
||||
· `agnes-video-2.5` 是 `agnes-video-2.5-flash` 的子串,不能互相串味
|
||||
"""
|
||||
sys.path.insert(0, str(_ROOT / "scripts"))
|
||||
import sync_models as sm
|
||||
|
||||
ids = {"agnes-3.0-flash", "agnes-2.5-flash", "agnes-video-2.5", "agnes-video-2.5-flash",
|
||||
"agnes-video-v2.0", "agnes-2.5-pro"}
|
||||
|
||||
real = ("## 视频模型\n### 当前优惠\n"
|
||||
"* `agnes-video-v2.0` 当前免费。\n"
|
||||
"* `agnes-video-2.5` 按输出视频分辨率和总计费时长计费;输入图片前 5 张免费,第 6 张起计费。\n"
|
||||
"* `agnes-video-2.5-flash` 采用相同计费公式,当前限时免费。\n"
|
||||
"### 计费规则\n输入图片前 5 张免费。\n")
|
||||
got = sm._agnes_free_map(real, ids)
|
||||
assert got == {"agnes-video-v2.0": True, "agnes-video-2.5-flash": "limited"}, got
|
||||
|
||||
# 改口径 → 不再免费(否则同步会一直把「免费」标签留在配置里)
|
||||
changed = ("### 当前优惠\n* `agnes-3.0-flash` 当前按刊例价计费,暂无折扣。\n"
|
||||
"* `agnes-2.5-flash` 当前均免费。\n")
|
||||
assert sm._agnes_free_map(changed, ids) == {"agnes-2.5-flash": True}
|
||||
|
||||
# 下一小节里的「免费」不能串进本轮判定
|
||||
boundary = "### 当前优惠\n* `agnes-video-v2.0` 当前免费。\n### 计费规则\n输入图片前 5 张免费。\n"
|
||||
assert sm._agnes_free_map(boundary, ids) == {"agnes-video-v2.0": True}
|
||||
|
||||
|
||||
def test_agnes_free_apply_and_revoke_round_trip():
|
||||
"""agnes 免费标注落盘:加标注 / 限时 / 撤标注都要能改对,且不碰相邻手写注释。"""
|
||||
import yaml as _yaml
|
||||
sys.path.insert(0, str(_ROOT / "scripts"))
|
||||
import sync_models as sm
|
||||
|
||||
text = (
|
||||
"providers:\n"
|
||||
" agnes:\n"
|
||||
' name: "Agnes"\n'
|
||||
" models:\n"
|
||||
' - id: "agnes-3.0-flash"\n'
|
||||
' display_name: "Agnes 3.0 Flash"\n'
|
||||
' type: "text"\n'
|
||||
" # 手写注释:别动我\n"
|
||||
' - id: "agnes-video-2.5-flash"\n'
|
||||
' display_name: "Agnes Video 2.5 Flash"\n'
|
||||
' type: "video"\n'
|
||||
' - id: "agnes-video-v2.0"\n'
|
||||
' display_name: "Agnes Video V2.0"\n'
|
||||
' type: "video"\n'
|
||||
" free: true # 旧标注\n"
|
||||
)
|
||||
date = "2026-09-24"
|
||||
|
||||
def run(src, free_map):
|
||||
plan = {"add": {"opencode": {}, "agnes": {}}, "remove": {"opencode": [], "agnes": []},
|
||||
"price_set": {}, "price_add": {}, "proto_add": {}, "free_set": {},
|
||||
"agnes_free": dict(free_map)}
|
||||
new = sm.apply_plan(src, plan, date)
|
||||
assert sm.verify(new, _yaml.safe_load(src), plan) == [], "回读校验必须全过"
|
||||
return new, _yaml.safe_load(new)["providers"]["agnes"]["models"]
|
||||
|
||||
# ① 加标注:普通免费 + 限时免费
|
||||
text, models = run(text, {"agnes-3.0-flash": True, "agnes-video-2.5-flash": "limited"})
|
||||
by = {m["id"]: m for m in models}
|
||||
assert sm._cfg_free_state(by["agnes-3.0-flash"]) is True
|
||||
assert "free_limited" not in by["agnes-3.0-flash"]
|
||||
assert sm._cfg_free_state(by["agnes-video-2.5-flash"]) == "limited"
|
||||
assert "别动我" in text, "相邻手写注释必须原样保留"
|
||||
assert "旧标注" in text, "没在本次动作里的模型,标注行不许动"
|
||||
|
||||
# ② 撤标注(文档改口径)+ 限时 → 普通免费
|
||||
text, models = run(text, {"agnes-video-v2.0": None, "agnes-video-2.5-flash": True})
|
||||
by = {m["id"]: m for m in models}
|
||||
assert sm._cfg_free_state(by["agnes-video-v2.0"]) is None
|
||||
assert not [k for k in by["agnes-video-v2.0"] if k.startswith("free")], "撤标注要整行删干净"
|
||||
assert "旧标注" not in text
|
||||
assert sm._cfg_free_state(by["agnes-video-2.5-flash"]) is True
|
||||
assert "free_limited" not in by["agnes-video-2.5-flash"], "限时行要跟着删"
|
||||
assert sm._cfg_free_state(by["agnes-3.0-flash"]) is True, "不相关的模型不能被顺手改掉"
|
||||
|
||||
# ③ 幂等:同一份动作重放,结果逐字节一致
|
||||
plan = {"add": {"opencode": {}, "agnes": {}}, "remove": {"opencode": [], "agnes": []},
|
||||
"price_set": {}, "price_add": {}, "proto_add": {}, "free_set": {},
|
||||
"agnes_free": {"agnes-3.0-flash": True}}
|
||||
assert sm.apply_plan(sm.apply_plan(text, plan, date), plan, date) == \
|
||||
sm.apply_plan(text, plan, date)
|
||||
|
||||
|
||||
# 直接运行(非 pytest)—— 必须留在文件末尾,见上方 `test_image_request_goes_to_requested_model`
|
||||
# 之前的旁注:运行器只会收集执行到这一行时已经存在的 globals。
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user