feat: 免费模型在前端「模型与供应商」页可见(free 字段 + 绿色「免费」标签)
- 后端:ModelInfo 增加 free 字段(yaml models[].free,_opt_bool 校验)、all_models() 带出、 /v1/models 暴露 free(别名随目标继承,与 vision/params 同源) - 配置:space-bunny-free 标 free: true(与 display_name 的「(免费)」双保险) - 前端:Models.vue「能力」列新增绿色「免费」标签(bolt 图标 + 悬浮说明)、测速行同步标一颗闪电; i18n 中英各 +2 键(freeTag/freeHint),753/753 对称 - 测试:新增 test_models_payload_marks_free_models(免费模型必须 free=true、付费必须 false、 每个模型都要带该字段),全套 192 passed / 0 failed - README:免费模型说明补「三处标注」口径
This commit is contained in:
1 parent
68ddccba53
commit
70c82d4ca7
8 files changed
+47
-2
No files matched your search
@@ -1667,6 +1667,20 @@ def test_models_endpoint_objects_are_all_model():
|
||||
assert all("created" in x and "owned_by" in x for x in j["data"]), j["data"][0]
|
||||
|
||||
|
||||
def test_models_payload_marks_free_models():
|
||||
"""2026-09-21: 免费模型要在 /v1/models 里带 free=true(前端「能力」列据此打「免费」标签)。"""
|
||||
from fastapi.testclient import TestClient
|
||||
import app.main as m
|
||||
client = TestClient(m.app)
|
||||
data = client.get("/v1/models").json()["data"]
|
||||
free_ids = [x["id"] for x in data if x.get("free")]
|
||||
assert "space-bunny-free" in free_ids, f"免费模型没标出来:{free_ids}"
|
||||
# 反向:付费模型必须是 free=false(不能因为字段缺失而误标)
|
||||
paid = next(x for x in data if x["id"] == "deepseek-v4.1-flash")
|
||||
assert paid["free"] is False, paid
|
||||
assert all("free" in x for x in data), "每个模型都要带 free 字段(缺字段=前端标签会闪)"
|
||||
|
||||
|
||||
def test_empty_messages_rejected_and_stream_strict():
|
||||
"""P2: 空 messages / 拼错的 stream 类型应在入参处被拒(而非打到上游变 502)。"""
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
Reference in new issue
Block a user