mistral_tools.conversation

High-level interface to the Mistral completion API

Classes

ModelConversation(*, api_key, tool_register, ...)

High-level interface to the Mistral completion API

class mistral_tools.conversation.ModelConversation(*, api_key, tool_register, model, rate_limit: float | RateLimiter = 1.1, system_prompt: str | None = None)[source]

High-level interface to the Mistral completion API

Handles keeping track of a conversation with a model, and sending messages to the model, as well as automatically handling tool calls.

add_system_prompt(prompt)[source]

Add a system prompt to the conversation

add_message(prompt)[source]

Add a user message to the conversation

add_prefix(prefix)[source]

Add a prefix to the conversation

simulate_assistant_message(content, *, tool_calls=None)[source]

Add an assistant message to the conversation

send(*, tool_choice: Literal['any', 'auto', 'none'] = 'auto')[source]

Send the conversation to the model and get the response

handle_response(response_message)[source]

Handle the response from the model

handle_tool_call(tool_name, tool_parameters, tool_call_id)[source]

Handle a tool call from the model

changes_sync_state(state: bool)[source]

Change the synchronization state

context manager that sets the synced state to the given state unless the content failed, in which case the sync state is assumed to be false (ie failure -> not synced)