eigent/backend/tests/app/model/test_model_platform.py
Wendong-Fan 5ca2caf557
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Pre-commit / pre-commit (push) Waiting to run
Test / Run Python Tests (push) Waiting to run
feat: support grok,mistral,sambanova (#1321)
2026-02-21 14:15:01 +08:00

51 lines
1.9 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"
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="grok",
optional_model_platform="ModelArk",
)
assert item.model_platform == "openai-compatible-model"
assert item.optional_model_platform == "openai-compatible-model"