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}") 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],