SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
4.9 KB · 66 lines python
Raw Blame History
1import pytest23from aiatlas.connectors.labs.mistral import DOCS, NEWS_RSS, MistralConnector4from aiatlas.sdk.facts import Target5from tests.conftest import claims_of, entity_names, extract_from_fixture, fixture_path678@pytest.fixture9def connector() -> MistralConnector:10    return MistralConnector()111213async def test_models_overview(connector):14    facts = await extract_from_fixture(connector, Target(url=f"{DOCS}/models", doc_type="model_docs", key="models"), fixture_path("mistral", "models.html"))15    models = entity_names(facts, "model")16    assert len(models) >= 5517    medium = claims_of(facts, "Mistral Medium 3.5")18    assert medium["license"] == "MIT-Modified" and medium["license_raw"] == "Modified MIT" and medium["openness"] == "open-weights" and medium["version"] == "26.04"19    assert medium["weights_available"] is True and medium["official_url"] == f"{DOCS}/models/mistral-medium-3-5-26-04"20    small = claims_of(facts, "Mistral Small 4")21    assert small["license"] == "Apache-2.0" and small["license_raw"] == "Apache 2.0" and small["openness"] == "open-weights"    # badge → ontology key22    mrl = next((claims_of(facts, e.name) for e in facts.entities if e.entity_type == "model" and claims_of(facts, e.name).get("license_raw") == "MRL"), None)23    if mrl is not None:24        assert mrl["license"] == "Mistral-Research" and mrl["openness"] == "restricted-weights"                              # research licence ≠ open weights25    medium_ref = next(e for e in facts.entities if e.name == "Mistral Medium 3.5")26    assert medium_ref.family is not None and medium_ref.family.name == "Mistral" and medium_ref.family.organization.name == "Mistral AI"27    # deprecation table: versioned API ids, dates (US format), status vs. today, alternative28    m31 = next(e for e in facts.entities if e.name == "Mistral Medium 3.1")29    assert m31.identifiers == {"mistral_docs_slug": "mistral-medium-3-1-25-08", "mistral_model_id": "mistral-medium-2508"}30    c31 = claims_of(facts, "Mistral Medium 3.1")31    assert c31["api_model_id"] == "mistral-medium-2508" and c31["deprecation_date"] == "2026-05-22" and c31["retirement_date"] == "2026-08-31"32    assert c31["status"] == "retired"33    assert ("Mistral Medium 3.1", "Mistral Medium 3.5") in {(r.subject.name, r.object.name) for r in facts.relations if r.predicate == "superseded_by"}34    # third-party model hosted on La Plateforme keeps its own developer35    glm = next(e for e in facts.entities if e.name == "Z.ai GLM 5.2")36    assert glm.organization is not None and glm.organization.slug_hint == "zhipu"37    assert any(r.predicate == "available_through" and r.subject is glm for r in facts.relations)38    pages = [t for t in facts.targets if t.doc_type == "model_page"]39    assert len(pages) == 20 and pages[0].url == f"{DOCS}/models/mistral-medium-3-5-26-04"40    # a reused display name never folds distinct versions together41    codestral = sorted(e.name for e in facts.entities if e.entity_type == "model" and e.name.startswith("Codestral") and "Embed" not in e.name and "Mamba" not in e.name)42    assert codestral == ["Codestral", "Codestral 24.05", "Codestral 25.01"]43    assert claims_of(facts, "Codestral 25.01")["api_model_id"] == "codestral-2501"44    assert len({(e.name.lower()) for e in facts.entities if e.entity_type == "model"}) == len([e for e in facts.entities if e.entity_type == "model"])454647async def test_model_page(connector):48    target = Target(url=f"{DOCS}/models/mistral-medium-3-5-26-04", doc_type="model_page", key="model:mistral-medium-3-5-26-04", meta={"slug": "mistral-medium-3-5-26-04"})49    facts = await extract_from_fixture(connector, target, fixture_path("mistral", "model-mistral-medium-3-5.html"))50    m = claims_of(facts, "Mistral Medium 3.5")51    assert m["context_length"] == 256_000 and m["license"] == "MIT-Modified" and m["license_raw"] == "Modified MIT" and m["openness"] == "open-weights"52    assert m["api_alias"] == "mistral-medium-latest" and m["api_aliases"] == ["mistral-medium-latest"] and m["tool_calling"] is True and m["structured_output"] is True53    assert {"function_calling", "structured_output"} <= set(m["capabilities"])54    assert len(facts.prices) == 155    p = facts.prices[0]56    assert (p.input_per_mtok, p.output_per_mtok) == (1.5, 7.5) and p.features["eur_input_per_mtok"] == 1.25 and p.provider.identifiers["registry_provider"] == "mistral"57    ref = next(e for e in facts.entities if e.entity_type == "model")58    assert ref.identifiers == {"mistral_docs_slug": "mistral-medium-3-5-26-04"}596061async def test_news_feed(connector):62    facts = await extract_from_fixture(connector, Target(url=NEWS_RSS, doc_type="feed", key="news"), fixture_path("mistral", "news.rss.xml"), content_type="application/rss+xml")63    assert len(facts.events) == 8664    assert facts.events[0].summary.startswith("Mistral AI: Cloudera and Mistral Partner") and facts.events[0].effective_at.date().isoformat() == "2026-09-10"65    assert any(e.category == "release" and "Mistral Small 4" in e.summary for e in facts.events)66