Skip to content
Merged
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
3 changes: 3 additions & 0 deletions examples/mistral/chat/function_calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ 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))
messages.append(UserMessage(content="My transaction ID is T1001."))

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")
Expand Down Expand Up @@ -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}")
4 changes: 2 additions & 2 deletions src/mistralai/client/conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
Loading