refactor(model-permissions): 简化 allowed_models 为纯列表格式

移除按 API 格式区分的字典模式(Dict[str, List[str]]),统一使用简单列表格式。

- 删除 normalize_allowed_models 的 api_format 参数
- 删除 check_model_allowed 的 api_format 参数
- 简化 merge_allowed_models 为直接列表交集
- 移除前端的字典模式兼容代码和警告 UI
- 删除 is_format_mode、convert_to_format_mode 等辅助函数
This commit is contained in:
fawney19
2026-01-14 17:57:21 +08:00
parent 133f3108f0
commit b272109055
9 changed files with 62 additions and 345 deletions

View File

@@ -6,7 +6,6 @@ class TestCheckModelAllowedWithAliases:
is_allowed, matched = check_model_allowed_with_aliases(
model_name="gpt-4o",
allowed_models=["gpt-4o"],
api_format="OPENAI",
resolved_model_name="gpt-4o",
model_aliases=[r"gpt-4o-.*"],
)
@@ -17,7 +16,6 @@ class TestCheckModelAllowedWithAliases:
is_allowed, matched = check_model_allowed_with_aliases(
model_name="target",
allowed_models=["b", "a"],
api_format="OPENAI",
resolved_model_name="target",
model_aliases=[r".*"],
)
@@ -28,7 +26,6 @@ class TestCheckModelAllowedWithAliases:
is_allowed, matched = check_model_allowed_with_aliases(
model_name="target",
allowed_models=["other-1", "allowed-1"],
api_format="OPENAI",
resolved_model_name="target",
model_aliases=[r".*-1"],
candidate_models={"allowed-1"},
@@ -40,11 +37,9 @@ class TestCheckModelAllowedWithAliases:
is_allowed, matched = check_model_allowed_with_aliases(
model_name="target",
allowed_models=["allowed-1"],
api_format="OPENAI",
resolved_model_name="target",
model_aliases=[r".*-1"],
candidate_models={"not-present"},
)
assert is_allowed is False
assert matched is None