refactor: 简化模型权限检查,移除 resolved_model_name 参数

- 从 check_model_allowed 和 check_model_allowed_with_mappings 移除 resolved_model_name 参数
- 优化匹配逻辑:先精确匹配 model_name,再检查 candidate_models 交集,最后进行映射匹配
- 更新 CacheAwareScheduler 中的相关调用,传入 provider_model_names 作为 candidate_models
- 同步更新测试用例
This commit is contained in:
fawney19
2026-01-23 00:57:47 +08:00
parent 7ef0488419
commit 08a3148ab3
6 changed files with 40 additions and 66 deletions

View File

@@ -6,7 +6,6 @@ class TestCheckModelAllowedWithMappings:
is_allowed, matched = check_model_allowed_with_mappings(
model_name="gpt-4o",
allowed_models=["gpt-4o"],
resolved_model_name="gpt-4o",
model_mappings=[r"gpt-4o-.*"],
)
assert is_allowed is True
@@ -16,7 +15,6 @@ class TestCheckModelAllowedWithMappings:
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["b", "a"],
resolved_model_name="target",
model_mappings=[r".*"],
)
assert is_allowed is True
@@ -26,7 +24,6 @@ class TestCheckModelAllowedWithMappings:
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["other-1", "allowed-1"],
resolved_model_name="target",
model_mappings=[r".*-1"],
candidate_models={"allowed-1"},
)
@@ -37,7 +34,6 @@ class TestCheckModelAllowedWithMappings:
is_allowed, matched = check_model_allowed_with_mappings(
model_name="target",
allowed_models=["allowed-1"],
resolved_model_name="target",
model_mappings=[r".*-1"],
candidate_models={"not-present"},
)