
    :i                         S SK r S SKJr  S SKJrJr  S SKJr  S SKJ	r	   " S S\	5      r
 " S S	\\5      r " S
 S\\5      r " S S\	5      r " S S\	5      r " S S\	5      r\" S\S9rg)    N)Enum)AnyTypeVar)field_validator)MistralBasec                   F    \ rS rSr% Sr\\S'   Sr\\S'   \\\	4   \S'   Sr
g)	Function
   a6  Function definition for tools.

Attributes:
    name: The name of the function.
    description: A description of what the function does.
    parameters: 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"],
    ...     },
    ... )
name description
parameters N)__name__
__module____qualname____firstlineno____doc__str__annotations__r   dictr   __static_attributes__r       e/home/james-whalen/.local/lib/python3.13/site-packages/mistral_common/protocol/instruct/tool_calls.pyr	   r	   
   s&    2 IKS#Xr   r	   c                       \ rS rSrSrSrSrg)	ToolTypes)   zqEnum of tool types.

Attributes:
   function: A function tool.

Examples:
    >>> tool_type = ToolTypes.function
functionr   N)r   r   r   r   r   r   r   r   r   r   r   r   )   s     Hr   r   c                   $    \ rS rSrSrSrSrSrSrg)
ToolChoice6   zEnum of tool choice types.

Attributes:
    auto: Automatically choose the tool.
    none: Do not use any tools.
    any: Use any tool.

Examples:
    >>> tool_choice = ToolChoice.auto
autononeanyr   N)	r   r   r   r   r   r"   r#   r$   r   r   r   r   r    r    6   s    	 DD
Cr   r    c                       \ rS rSr% Sr\R                  r\\S'   \	\S'   S\
\\4   4S jr\S\
\\4   SS 4S j5       rS	rg
)ToolG   a  Tool definition.

Attributes:
    type: The type of the tool.
    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"],
    ...         },
    ...     ),
    ... )
typer   returnc                 "    U R                  5       $ N
model_dumpselfs    r   	to_openaiTool.to_openaie         r   openai_toolc                 $    U R                  U5      $ r+   model_validate)clsr3   s     r   from_openaiTool.from_openaih   s    !!+..r   r   N)r   r   r   r   r   r   r   r(   r   r	   r   r   r   r0   classmethodr8   r   r   r   r   r&   r&   G   s]    4  ((D)(!4S> ! /d38n / / /r   r&   c                   d    \ rS rSr% Sr\\S'   \\S'   \" SSS9S\\\\	4   -  S\4S	 j5       r
S
rg)FunctionCallm   a-  Function call.

Attributes:
    name: The name of the function to call.
    arguments: The arguments to pass to the function.

Examples:
    >>> function_call = FunctionCall(
    ...     name="get_current_weather",
    ...     arguments={"location": "San Francisco, CA", "unit": "celsius"},
    ... )
r   	argumentsbefore)modevr)   c                 \    [        U[        5      (       a  [        R                  " U5      $ U$ )zConvert arguments to a JSON string if they are a dictionary.

Args:
    v: The arguments to validate.

Returns:
    The arguments as a JSON string.
)
isinstancer   jsondumps)r7   rA   s     r   validate_argumentsFunctionCall.validate_arguments~   s$     a::a= r   r   N)r   r   r   r   r   r   r   r   r   r   rF   r   r   r   r   r<   r<   m   sG     IN[x03c3h#7 C  1r   r<   c                       \ rS rSr% SrSr\\S'   \R                  r
\\S'   \\S'   S\\\4   4S jr\S	\\\4   SS 4S
 j5       rSrg)ToolCall   a  Tool call.

Attributes:
    id: The ID of the tool call. Required for V3+ tokenization
    type: The type of the tool call.
    function: The function call.

Examples:
    >>> tool_call = ToolCall(
    ...     id="call_abc123",
    ...     function=FunctionCall(
    ...         name="get_current_weather",
    ...         arguments={"location": "San Francisco, CA", "unit": "celsius"},
    ...     ),
    ... )
nullidr(   r   r)   c                 "    U R                  5       $ r+   r,   r.   s    r   r0   ToolCall.to_openai   r2   r   	tool_callc                 $    U R                  U5      $ r+   r5   )r7   rO   s     r   r8   ToolCall.from_openai   s    !!),,r   r   N)r   r   r   r   r   rL   r   r   r   r   r(   r<   r   r   r0   r:   r8   r   r   r   r   rI   rI      sg    " B((D)(!4S> ! -DcN -z - -r   rI   ToolType)bound)rD   enumr   typingr   r   pydanticr   mistral_common.baser   r	   r   r   r    r&   r<   rI   rR   r   r   r   <module>rX      sp       $ +{ >
T 
d "#/; #/L; @-{ -< :T*r   