fix: 修复模型权限正则匹配逻辑及相关缓存清除

- 修复 model_mappings 正则匹配不再受 candidate_models 限制
- Provider 启用/禁用/删除时清除 GlobalModel 解析缓存
- 优先级管理对话框中启用的 Provider 排在禁用的前面
- 修复请求时间线 skipped 状态颜色适配主题
This commit is contained in:
fawney19
2026-01-23 16:10:53 +08:00
parent 3963e424f8
commit 6f597a5f54
6 changed files with 77 additions and 26 deletions

View File

@@ -20,7 +20,8 @@ class TestCheckModelAllowedWithMappings:
assert is_allowed is True
assert matched == "a"
def test_mapping_match_respects_candidate_models(self) -> None:
def test_mapping_match_with_candidate_intersection(self) -> None:
"""当 candidate_models 和 allowed_models 有交集时,应优先返回交集中的模型"""
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["other-1", "allowed-1"],
@@ -28,14 +29,29 @@ class TestCheckModelAllowedWithMappings:
candidate_models={"allowed-1"},
)
assert is_allowed is True
# 交集精确匹配优先于正则匹配
assert matched == "allowed-1"
def test_mapping_match_candidate_models_no_intersection(self) -> None:
def test_mapping_match_without_candidate_intersection(self) -> None:
"""当 candidate_models 和 allowed_models 没有交集时,应继续尝试正则匹配"""
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["allowed-1"],
model_mappings=[r".*-1"],
candidate_models={"not-present"},
)
# 正则匹配应该成功,因为 allowed-1 匹配 .*-1
assert is_allowed is True
assert matched == "allowed-1"
def test_mapping_match_no_regex_match(self) -> None:
"""当正则不匹配 allowed_models 时,应返回 False"""
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["allowed-2"],
model_mappings=[r"other-.*"],
candidate_models={"not-present"},
)
# 正则 other-.* 不匹配 allowed-2
assert is_allowed is False
assert matched is None