Clients.FFMistralSmall

Mistral Small client with chat completions, streaming, function calling, and tool use.

Mistral Small client with chat completions, streaming, function calling, and tool use.

class FFMistralSmall(config=None, **kwargs)[source]

Bases: FFAIClientBase

Mistral Small client with chat completions, function calling, and tool use.

Wraps the mistralai SDK to provide a consistent FFAIClientBase interface with built-in retry, conversation tracking, and tool-call handling for the Mistral Small family of models.

Parameters:
  • config (dict | None) – Optional configuration dictionary.

  • **kwargs – Keyword overrides for model, temperature, max_tokens, etc.

conversation_history: list[dict[str, Any]]
get_conversation_history()[source]

Get the conversation history.

Return type:

list[dict[str, Any]]

set_conversation_history(history)[source]

Set the conversation history.

Parameters:

history (list[dict[str, Any]])

Return type:

None

clone()[source]

Create a fresh clone of this client with empty history.

Return type:

FFMistralSmall

generate_response(prompt, model=None, system_instructions=None, temperature=None, max_tokens=None, max_completion_tokens=None, top_p=None, presence_penalty=None, frequency_penalty=None, stop=None, response_format=None, tools=None, tool_choice=None, safe_mode=None, **kwargs)[source]

Generate a response from the model with robust parameter handling.

Parameters:
  • prompt (str) – User’s input text

  • model (str | None) – Model to use (overrides default)

  • system_instructions (str | None) – System instructions (overrides default)

  • temperature (float | None) – Controls randomness (0-1)

  • max_tokens (int | None) – Maximum tokens to generate

  • max_completion_tokens (int | None) – Alternative name for max_tokens (for compatibility)

  • top_p (float | None) – Nucleus sampling parameter

  • presence_penalty (float | None) – Penalizes repeated tokens

  • frequency_penalty (float | None) – Penalizes frequent tokens

  • stop (list[str] | None) – List of strings that stop generation when encountered

  • response_format (str | dict | type | None) – Format of the response (“text” or “json”)

  • tools (list[dict] | None) – List of tools to make available to the model

  • tool_choice (str | None) – Tool choice strategy (“auto”, “none”, or specific tool)

  • safe_mode (bool | None) – Whether to enable Mistral’s safe mode

  • **kwargs – Any additional parameters that may be passed but aren’t used

Returns:

The model’s response as a string

Return type:

str

add_tool_result(tool_call_id, content)[source]

Add a tool result to the conversation history.

Parameters:
  • tool_call_id (str) – The ID of the tool call this is responding to

  • content (Any) – The content/result from the tool

Return type:

None

clear_conversation()[source]

Clear the conversation history.

test_connection()[source]

Test the connection to the Mistral API endpoint.

Returns:

True if connection is successful, False otherwise

Return type:

bool

Classes

class FFMistralSmall(config=None, **kwargs)[source]

Bases: FFAIClientBase

Mistral Small client with chat completions, function calling, and tool use.

Wraps the mistralai SDK to provide a consistent FFAIClientBase interface with built-in retry, conversation tracking, and tool-call handling for the Mistral Small family of models.

Parameters:
  • config (dict | None) – Optional configuration dictionary.

  • **kwargs – Keyword overrides for model, temperature, max_tokens, etc.

model: str
system_instructions: str
conversation_history: list[dict[str, Any]]
get_conversation_history()[source]

Get the conversation history.

Return type:

list[dict[str, Any]]

set_conversation_history(history)[source]

Set the conversation history.

Parameters:

history (list[dict[str, Any]])

Return type:

None

clone()[source]

Create a fresh clone of this client with empty history.

Return type:

FFMistralSmall

configure_retry(retry_config=None)

Configure retry behavior for this client.

Parameters:

retry_config (dict[str, Any] | None) – Optional retry configuration. If None, uses global config.

Return type:

None

static get_default_retry_config()

Get default retry configuration from global config.

Returns:

Dictionary with retry configuration parameters.

Return type:

dict[str, Any]

property last_cost_usd: float

Estimated cost in USD from the most recent generate_response() call.

property last_duration_ms: float | None

Wall-clock duration in ms of the most recent generate_response() call.

property last_usage: TokenUsage | None

Token usage from the most recent generate_response() call.

retry_config: dict[str, Any] | None = None
generate_response(prompt, model=None, system_instructions=None, temperature=None, max_tokens=None, max_completion_tokens=None, top_p=None, presence_penalty=None, frequency_penalty=None, stop=None, response_format=None, tools=None, tool_choice=None, safe_mode=None, **kwargs)[source]

Generate a response from the model with robust parameter handling.

Parameters:
  • prompt (str) – User’s input text

  • model (str | None) – Model to use (overrides default)

  • system_instructions (str | None) – System instructions (overrides default)

  • temperature (float | None) – Controls randomness (0-1)

  • max_tokens (int | None) – Maximum tokens to generate

  • max_completion_tokens (int | None) – Alternative name for max_tokens (for compatibility)

  • top_p (float | None) – Nucleus sampling parameter

  • presence_penalty (float | None) – Penalizes repeated tokens

  • frequency_penalty (float | None) – Penalizes frequent tokens

  • stop (list[str] | None) – List of strings that stop generation when encountered

  • response_format (str | dict | type | None) – Format of the response (“text” or “json”)

  • tools (list[dict] | None) – List of tools to make available to the model

  • tool_choice (str | None) – Tool choice strategy (“auto”, “none”, or specific tool)

  • safe_mode (bool | None) – Whether to enable Mistral’s safe mode

  • **kwargs – Any additional parameters that may be passed but aren’t used

Returns:

The model’s response as a string

Return type:

str

add_tool_result(tool_call_id, content)[source]

Add a tool result to the conversation history.

Parameters:
  • tool_call_id (str) – The ID of the tool call this is responding to

  • content (Any) – The content/result from the tool

Return type:

None

clear_conversation()[source]

Clear the conversation history.

test_connection()[source]

Test the connection to the Mistral API endpoint.

Returns:

True if connection is successful, False otherwise

Return type:

bool