The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Refactor] Improve type safety in Mistral chat transformation
Cole McIntosh82334ce52214
diff --git a/litellm/llms/mistral/mistral_chat_transformation.py b/litellm/llms/mistral/mistral_chat_transformation.pyindex 3c90380f12b..b886e3cc964 100644--- a/litellm/llms/mistral/mistral_chat_transformation.py+++ b/litellm/llms/mistral/mistral_chat_transformation.py@@ -6,7 +6,7 @@ Why separate file? Make it easy to see how transformation worksDocs - https://docs.mistral.ai/api/"""-from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload+from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload, castfrom litellm.litellm_core_utils.prompt_templates.common_utils import (handle_messages_with_content_list_to_str_conversion,@@ -251,17 +251,17 @@ Then provide a clear, concise answer based on your reasoning."""if msg.get("role") == "system":existing_content = msg.get("content", "")reasoning_prompt = self._get_mistral_reasoning_system_prompt()- messages[i] = {+ messages[i] = cast(AllMessageValues, {**msg,"content": f"{reasoning_prompt}\n\n{existing_content}"- }+ })breakelse:# Add new system message with reasoning instructions- reasoning_message: AllMessageValues = {+ reasoning_message: AllMessageValues = cast(AllMessageValues, {"role": "system","content": self._get_mistral_reasoning_system_prompt()- }+ })messages = [reasoning_message] + messages# Remove the internal flag