mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
refactor: 将模型别名(alias)统一重命名为模型映射(mapping)
- 重命名 API: alias-mapping-preview -> mapping-preview - 重命名类型: AliasMatchedModel -> MappingMatchedModel 等 - 重命名字段: model_aliases -> model_mappings, alias_matched_model -> mapping_matched_model - 重命名前端组件: ModelAliasesTab -> ModelMappingsTab - 重命名验证函数: validate_model_aliases -> validate_model_mappings - 同步更新相关测试用例 - 补充 ModelService 中新增/批量创建模型时的缓存失效逻辑
This commit is contained in:
@@ -1,44 +1,44 @@
|
||||
from src.core.model_permissions import check_model_allowed_with_aliases
|
||||
from src.core.model_permissions import check_model_allowed_with_mappings
|
||||
|
||||
|
||||
class TestCheckModelAllowedWithAliases:
|
||||
class TestCheckModelAllowedWithMappings:
|
||||
def test_exact_match_returns_allowed_without_mapping(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_aliases(
|
||||
is_allowed, matched = check_model_allowed_with_mappings(
|
||||
model_name="gpt-4o",
|
||||
allowed_models=["gpt-4o"],
|
||||
resolved_model_name="gpt-4o",
|
||||
model_aliases=[r"gpt-4o-.*"],
|
||||
model_mappings=[r"gpt-4o-.*"],
|
||||
)
|
||||
assert is_allowed is True
|
||||
assert matched is None
|
||||
|
||||
def test_alias_match_is_deterministic(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_aliases(
|
||||
def test_mapping_match_is_deterministic(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_mappings(
|
||||
model_name="target",
|
||||
allowed_models=["b", "a"],
|
||||
resolved_model_name="target",
|
||||
model_aliases=[r".*"],
|
||||
model_mappings=[r".*"],
|
||||
)
|
||||
assert is_allowed is True
|
||||
assert matched == "a"
|
||||
|
||||
def test_alias_match_respects_candidate_models(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_aliases(
|
||||
def test_mapping_match_respects_candidate_models(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_mappings(
|
||||
model_name="target",
|
||||
allowed_models=["other-1", "allowed-1"],
|
||||
resolved_model_name="target",
|
||||
model_aliases=[r".*-1"],
|
||||
model_mappings=[r".*-1"],
|
||||
candidate_models={"allowed-1"},
|
||||
)
|
||||
assert is_allowed is True
|
||||
assert matched == "allowed-1"
|
||||
|
||||
def test_alias_match_candidate_models_no_intersection(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_aliases(
|
||||
def test_mapping_match_candidate_models_no_intersection(self) -> None:
|
||||
is_allowed, matched = check_model_allowed_with_mappings(
|
||||
model_name="target",
|
||||
allowed_models=["allowed-1"],
|
||||
resolved_model_name="target",
|
||||
model_aliases=[r".*-1"],
|
||||
model_mappings=[r".*-1"],
|
||||
candidate_models={"not-present"},
|
||||
)
|
||||
assert is_allowed is False
|
||||
|
||||
Reference in New Issue
Block a user