Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
"llama-3.3-70b": "Llama-3.3-70B-Instruct",
"llama-4-scout": "Llama-4-Scout-17B-16E-Instruct-FP8",
"llama-4-maverick": "Llama-4-Maverick-17B-128E-Instruct-FP8",
# Mistral models
"mistral-large-latest": "mistral-large-2411",
"mistral-small-latest": "mistral-small-2503",
"codestral-latest": "codestral-2501",
"ministral-8b-latest": "ministral-8b-2410",
"ministral-3b-latest": "ministral-3b-2410",
"pixtral-large-latest": "pixtral-large-2411",
"pixtral-12b-latest": "pixtral-12b-2409",
}

_MODEL_INFO: Dict[str, ModelInfo] = {
Expand Down Expand Up @@ -441,6 +449,94 @@
"structured_output": True,
"multiple_system_messages": True,
},
"mistral-large-2411": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MISTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"mistral-small-2503": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MISTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"codestral-2501": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.CODESRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"ministral-8b-2410": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MINISTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"ministral-3b-2410": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MINISTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"pixtral-large-2411": {
"vision": True,
"function_calling": True,
"json_output": True,
"family": ModelFamily.PIXTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"pixtral-12b-2409": {
"vision": True,
"function_calling": True,
"json_output": True,
"family": ModelFamily.PIXTRAL,
"structured_output": True,
"multiple_system_messages": False,
},
"open-mistral-7b": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MISTRAL,
"structured_output": False,
"multiple_system_messages": False,
},
"open-mixtral-8x7b": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MISTRAL,
"structured_output": False,
"multiple_system_messages": False,
},
"open-mixtral-8x22b": {
"vision": False,
"function_calling": True,
"json_output": True,
"family": ModelFamily.MISTRAL,
"structured_output": False,
"multiple_system_messages": False,
},
"open-codestral-mamba": {
"vision": False,
"function_calling": False,
"json_output": True,
"family": ModelFamily.OPEN_CODESRAL_MAMBA,
"structured_output": False,
"multiple_system_messages": False,
},
}

_MODEL_TOKEN_LIMITS: Dict[str, int] = {
Expand Down Expand Up @@ -491,11 +587,23 @@
"Llama-3.3-70B-Instruct": 128000,
"Llama-4-Scout-17B-16E-Instruct-FP8": 128000,
"Llama-4-Maverick-17B-128E-Instruct-FP8": 128000,
"mistral-large-2411": 131072,
"mistral-small-2503": 131072,
"codestral-2501": 262144,
"ministral-8b-2410": 131072,
"ministral-3b-2410": 131072,
"pixtral-large-2411": 131072,
"pixtral-12b-2409": 131072,
"open-mistral-7b": 32768,
"open-mixtral-8x7b": 32768,
"open-mixtral-8x22b": 65536,
"open-codestral-mamba": 262144,
}

GEMINI_OPENAI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/"
ANTHROPIC_OPENAI_BASE_URL = "https://api.anthropic.com/v1/"
LLAMA_API_BASE_URL = "https://api.llama.com/compat/v1/"
MISTRAL_API_BASE_URL = "https://api.mistral.ai/v1/"


def resolve_model(model: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,13 @@ def __init__(self, **kwargs: Unpack[OpenAIClientConfiguration]):
copied_args["base_url"] = _model_info.LLAMA_API_BASE_URL
if "api_key" not in copied_args and "LLAMA_API_KEY" in os.environ:
copied_args["api_key"] = os.environ["LLAMA_API_KEY"]
if copied_args["model"].startswith(
("mistral-", "codestral-", "ministral-", "pixtral-", "open-mistral-", "open-codestral-", "open-mixtral-")
):
if "base_url" not in copied_args:
copied_args["base_url"] = _model_info.MISTRAL_API_BASE_URL
if "api_key" not in copied_args and "MISTRAL_API_KEY" in os.environ:
copied_args["api_key"] = os.environ["MISTRAL_API_KEY"]

client = _openai_client_from_config(copied_args)
create_args = _create_args_from_config(copied_args)
Expand Down
24 changes: 24 additions & 0 deletions python/packages/autogen-ext/tests/models/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import pytest
from autogen_core.models import ModelFamily
from autogen_ext.models._utils.parse_r1_content import parse_r1_content
from autogen_ext.models.openai._model_info import (
MISTRAL_API_BASE_URL,
get_info,
resolve_model,
)


def test_parse_r1_content() -> None:
Expand Down Expand Up @@ -41,3 +47,21 @@ def test_parse_r1_content() -> None:
thought, content = parse_r1_content(content)
assert thought is None
assert content == "</think>Hello, <think>world"


def test_mistral_model_info() -> None:
assert resolve_model("mistral-large-latest") == "mistral-large-2411"
assert resolve_model("codestral-latest") == "codestral-2501"
assert resolve_model("pixtral-large-latest") == "pixtral-large-2411"

info = get_info("mistral-large-latest")
assert info["family"] == ModelFamily.MISTRAL
assert info["function_calling"] is True
assert info["json_output"] is True
assert info["structured_output"] is True
assert info["multiple_system_messages"] is False

assert get_info("pixtral-large-latest")["vision"] is True
assert get_info("open-codestral-mamba")["function_calling"] is False

assert MISTRAL_API_BASE_URL == "https://api.mistral.ai/v1/"