mistral_common.protocol.instruct.tool_calls
Function(**data)
Bases: MistralBase
Function definition for tools.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the function. |
description |
str
|
A description of what the function does. |
parameters |
Dict[str, Any]
|
The parameters the functions accepts, described as a JSON Schema object. |
Examples:
>>> function = Function(
... name="get_current_weather",
... description="Get the current weather in a given location",
... parameters={
... "type": "object",
... "properties": {
... "location": {
... "type": "string",
... "description": "The city and state, e.g. San Francisco, CA",
... },
... "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
... },
... "required": ["location"],
... },
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
FunctionCall(**data)
Bases: MistralBase
Function call.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the function to call. |
arguments |
str
|
The arguments to pass to the function. |
Examples:
>>> function_call = FunctionCall(
... name="get_current_weather",
... arguments={"location": "San Francisco, CA", "unit": "celsius"},
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
validate_arguments(v)
Convert arguments to a JSON string if they are a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
Union[str, Dict[str, Any]]
|
The arguments to validate. |
required |
Returns:
Type | Description |
---|---|
str
|
The arguments as a JSON string. |
Source code in src/mistral_common/protocol/instruct/tool_calls.py
Tool(**data)
Bases: MistralBase
Tool definition.
Attributes:
Name | Type | Description |
---|---|---|
type |
ToolTypes
|
The type of the tool. |
function |
Function
|
The function definition. |
Examples:
>>> tool = Tool(
... function=Function(
... name="get_current_weather",
... description="Get the current weather in a given location",
... parameters={
... "type": "object",
... "properties": {
... "location": {
... "type": "string",
... "description": "The city and state, e.g. San Francisco, CA",
... },
... "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
... },
... "required": ["location"],
... },
... ),
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ToolCall(**data)
Bases: MistralBase
Tool call.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The ID of the tool call. Required for V3+ tokenization |
type |
ToolTypes
|
The type of the tool call. |
function |
FunctionCall
|
The function call. |
Examples:
>>> tool_call = ToolCall(
... id="call_abc123",
... function=FunctionCall(
... name="get_current_weather",
... arguments={"location": "San Francisco, CA", "unit": "celsius"},
... ),
... )