From c24a9a8cbc950cd7cf566bed39ed618e4ae6f222 Mon Sep 17 00:00:00 2001 From: maxime Date: Fri, 10 Apr 2026 15:31:15 +0200 Subject: [PATCH 1/2] fix: remove typehint causing ci error mypy treats the tuple unpacking of _process_deferred_responses as a redefinition when the variable is explicitly annotated above and caused ci to fail. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- src/mistralai/client/conversations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mistralai/client/conversations.py b/src/mistralai/client/conversations.py index f33c557b..ed2e0fce 100644 --- a/src/mistralai/client/conversations.py +++ b/src/mistralai/client/conversations.py @@ -98,7 +98,7 @@ async def run_async( from mistralai.extra.run.tools import get_function_calls # pylint: disable=import-outside-toplevel # Check if inputs contain deferred responses - process them - pending_tool_confirmations: Optional[List[models.ToolCallConfirmation]] = None + pending_tool_confirmations = None if inputs and isinstance(inputs, list): deferred_inputs = typing.cast( List[DeferredToolCallResponse], @@ -240,7 +240,7 @@ async def run_stream_async( from mistralai.extra.run.tools import get_function_calls # pylint: disable=import-outside-toplevel # Check if inputs contain deferred responses - process them - pending_tool_confirmations: Optional[List[models.ToolCallConfirmation]] = None + pending_tool_confirmations = None if inputs and isinstance(inputs, list): deferred_inputs = typing.cast( List[DeferredToolCallResponse], From 25e2f449c82d1ccb558f34cb5c1c4008b261ae3f Mon Sep 17 00:00:00 2001 From: andreaonofrei01 Date: Fri, 10 Apr 2026 15:34:39 +0200 Subject: [PATCH 2/2] fix: add null checks for message in function_calling example --- examples/mistral/chat/function_calling.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/mistral/chat/function_calling.py b/examples/mistral/chat/function_calling.py index 318e4e24..94d8899a 100644 --- a/examples/mistral/chat/function_calling.py +++ b/examples/mistral/chat/function_calling.py @@ -95,6 +95,7 @@ def retrieve_payment_date(data: dict[str, list[Any]], transaction_id: str) -> st response = client.chat.complete(model=model, messages=messages, tools=tools, temperature=0) +assert response.choices[0].message is not None print(response.choices[0].message.content) messages.append(AssistantMessage(content=response.choices[0].message.content)) @@ -102,6 +103,7 @@ def retrieve_payment_date(data: dict[str, list[Any]], transaction_id: str) -> st response = client.chat.complete(model=model, messages=messages, tools=tools, temperature=0) +assert response.choices[0].message is not None tool_calls = response.choices[0].message.tool_calls if not tool_calls: raise RuntimeError("Expected tool calls") @@ -130,4 +132,5 @@ def retrieve_payment_date(data: dict[str, list[Any]], transaction_id: str) -> st response = client.chat.complete(model=model, messages=messages, tools=tools, temperature=0) +assert response.choices[0].message is not None print(f"{response.choices[0].message.content}")