mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
测试 aware_scheduler 的模型支持检查逻辑
|
||||
|
||||
场景:
|
||||
- GlobalModel claude-haiku 配置了 model_aliases: ["haiku", "claude.*haiku.*"]
|
||||
- GlobalModel claude-haiku 配置了 model_mappings: ["haiku", "claude.*haiku.*"]
|
||||
- Provider A:Model 表有记录关联到 claude-haiku
|
||||
- Provider B:Model 表没有记录关联到 claude-haiku
|
||||
- 用户请求 haiku 模型
|
||||
|
||||
@@ -64,6 +64,6 @@ async def test_resolve_global_model_prefers_direct_match(monkeypatch) -> None:
|
||||
)
|
||||
db = _FakeSession(direct_match=global_model)
|
||||
|
||||
resolved = await ModelCacheService.resolve_global_model_by_name_or_alias(db, global_model.name)
|
||||
resolved = await ModelCacheService.resolve_global_model_by_name_or_mapping(db, global_model.name)
|
||||
assert resolved is global_model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user