diff --git a/static/js/providers.js b/static/js/providers.js index 832bfc1..1563e77 100644 --- a/static/js/providers.js +++ b/static/js/providers.js @@ -32,8 +32,8 @@ const _PROVIDERS = [ [/meta|llama(?![.\-_ ]?cpp)/i, ''], - // Mistral AI (official Simple Icons) - [/mistral/i, + // Mistral AI (official Simple Icons). Match Mixtral and Ministral too. + [/mi[sx]tral|ministral/i, ''], // Qwen (Tongyi Qianwen) — official geometric hexagonal logo diff --git a/tests/test_providers_mixtral_logo_js.py b/tests/test_providers_mixtral_logo_js.py new file mode 100644 index 0000000..6e60446 --- /dev/null +++ b/tests/test_providers_mixtral_logo_js.py @@ -0,0 +1,36 @@ +"""Pin the Mistral provider-logo pattern to cover Mixtral and Ministral. + +The pattern was /mistral/i, which does not match "mixtral" (note the x) or +"ministral" -- Mistral AI's flagship MoE and edge families -- so those models +rendered with no provider logo unless they carried a "mistralai/" prefix. +""" +import json +import shutil +import subprocess +from pathlib import Path + +import pytest + +_REPO = Path(__file__).resolve().parent.parent +_HELPER = _REPO / "static" / "js" / "providers.js" +pytestmark = pytest.mark.skipif(not shutil.which("node"), reason="node not on PATH") + + +def _has_logo(model): + js = ( + f"import {{ providerLogo }} from '{_HELPER.as_posix()}';" + f"console.log(JSON.stringify(providerLogo({json.dumps(model)}) !== null));" + ) + p = subprocess.run(["node", "--input-type=module"], input=js, capture_output=True, text=True, cwd=str(_REPO), timeout=30) + assert p.returncode == 0, p.stderr + return json.loads(p.stdout.strip()) + + +def test_mixtral_ministral_get_a_logo(): + assert _has_logo("mixtral-8x7b") is True + assert _has_logo("ministral-8b") is True + assert _has_logo("mistral-large-latest") is True + + +def test_unknown_vendor_has_no_logo(): + assert _has_logo("totally-unknown-model-xyz") is False