Skip to content

Commit 59dce11

Browse files
committed
fix: add initial support for magistral models
1 parent fb3bbfb commit 59dce11

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

gptme/llm/llm_openai.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,11 +604,17 @@ def _prepare_messages_for_api(
604604
messages = list(_prep_o1(messages))
605605

606606
# without this, deepseek-chat and reasoner can start outputting gibberish after tool calls
607-
# similarly, kimi-k2-instruct doesn't acknowledge tool responses/system messages without it
607+
# similarly, kimi-k2-instruct doesn't acknowledge tool responses/system messages without it, same with magistral
608608
# it probably applies to more models/providers, we should figure out which and perhaps make it default behavior
609+
# TODO: it seems to apply to a lot of reasoning models, should maybe be default behavior for all reasoning models?
609610
if any(
610611
m in model_meta.model
611-
for m in ["deepseek-reasoner", "deepseek-chat", "kimi-k2-instruct"]
612+
for m in [
613+
"deepseek-reasoner",
614+
"deepseek-chat",
615+
"kimi-k2-instruct",
616+
"magistral-medium-2506",
617+
]
612618
):
613619
messages = list(_prep_deepseek_reasoner(messages))
614620

gptme/llm/models.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ class _ModelDictMeta(TypedDict):
265265
},
266266
},
267267
"openrouter": {
268+
"mistralai/magistral-medium-2506": {
269+
"context": 41_000,
270+
"max_output": 40_000,
271+
"price_input": 2,
272+
"price_output": 5,
273+
# "supports_vision": True,
274+
"supports_reasoning": True,
275+
},
268276
"anthropic/claude-3.5-sonnet": {
269277
"context": 200_000,
270278
"max_output": 8192,
@@ -388,13 +396,13 @@ def _get_models_for_provider(
388396
provider: Provider, dynamic_fetch: bool = True
389397
) -> list[ModelMeta]:
390398
"""Get models for a specific provider, with optional dynamic fetching."""
399+
from . import get_available_models # fmt: skip
400+
391401
models_to_show = []
392402

393403
# Try dynamic fetching first for supported providers
394404
if dynamic_fetch and provider == "openrouter":
395405
try:
396-
from . import get_available_models
397-
398406
dynamic_models = get_available_models(provider)
399407
models_to_show = dynamic_models
400408
except Exception:

0 commit comments

Comments
 (0)