eigent/backend/tests/app/model/test_model_platform.py
Tao Sun 8e0f09ea33
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Pre-commit / pre-commit (push) Has been cancelled
Test / Run Python Tests (push) Has been cancelled
feat: add ernie in custom model (#1487)
Co-authored-by: bytecii <994513625@qq.com>
2026-03-12 19:20:07 +08:00

53 lines
2 KiB
Python

# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
from pydantic import BaseModel
from app.model.model_platform import (
NormalizedModelPlatform,
NormalizedOptionalModelPlatform,
normalize_model_platform,
normalize_optional_model_platform,
)
def test_normalize_model_platform_maps_known_aliases():
assert normalize_model_platform("grok") == "openai-compatible-model"
assert normalize_model_platform("z.ai") == "openai-compatible-model"
assert normalize_model_platform("ModelArk") == "openai-compatible-model"
assert normalize_model_platform("ernie") == "openai-compatible-model"
assert normalize_model_platform("llama.cpp") == "openai-compatible-model"
def test_normalize_model_platform_keeps_non_alias_unchanged():
assert normalize_model_platform("openai") == "openai"
assert normalize_model_platform("mistral") == "mistral"
def test_normalize_optional_model_platform_handles_none():
assert normalize_optional_model_platform(None) is None
def test_normalized_model_platform_type_applies_in_pydantic_model():
class _Model(BaseModel):
model_platform: NormalizedModelPlatform
optional_model_platform: NormalizedOptionalModelPlatform = None
item = _Model(
model_platform="ernie",
optional_model_platform="ModelArk",
)
assert item.model_platform == "openai-compatible-model"
assert item.optional_model_platform == "openai-compatible-model"