
    *`ii                        d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	  G d de	          Z
 G d d	ee          Z G d
 dee          Z G d de	          Z G d de	          Z G d de	          Z ede          ZdS )    N)Enum)AnyTypeVar)field_validator)MistralBasec                   F    e Zd ZU dZeed<   dZeed<   eeef         ed<   dS )Functiona  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
parametersN)	__name__
__module____qualname____doc__str__annotations__r   dictr        /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/mistral_common/protocol/instruct/tool_calls.pyr	   r	   
   sK          2 IIIKS#Xr   r	   c                       e Zd ZdZdZdS )	ToolTypeszEnum of tool types.

    Attributes:
       function: A function tool.

    Examples:
        >>> tool_type = ToolTypes.function
    functionN)r   r   r   r   r   r   r   r   r   r   )   s          HHHr   r   c                       e Zd ZdZdZdZdZdS )
ToolChoicezEnum 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anyN)r   r   r   r   r   r   r   r   r   r   r   r   6   s)        	 	 DD
CCCr   r   c                       e Zd ZU dZej        Zeed<   eed<   de	e
ef         fdZede	e
ef         dd fd            ZdS )	Toolaj  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                 *    |                                  S N
model_dumpselfs    r   	to_openaizTool.to_openaie          r   openai_toolc                 ,    |                      |          S r%   )model_validate)clsr,   s     r   from_openaizTool.from_openaih   s    !!+...r   N)r   r   r   r   r   r   r"   r   r	   r   r   r   r*   classmethodr0   r   r   r   r!   r!   G   s          4  (D)(((!4S> ! ! ! ! /d38n / / / / [/ / /r   r!   c                   t    e Zd ZU dZeed<   eed<    edd          deeeef         z  defd            Z	d	S )
FunctionCallaQ  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                 X    t          |t                    rt          j        |          S |S )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)r/   r7   s     r   validate_argumentszFunctionCall.validate_arguments~   s)     a 	!:a== r   N)
r   r   r   r   r   r   r   r   r   r<   r   r   r   r3   r3   m   s}           IIINNN_[x0003c3h#7 C    10  r   r3   c                       e Zd ZU dZdZeed<   ej        Z	eed<   e
ed<   deeef         fdZedeeef         dd fd	            Zd
S )ToolCalla  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                 *    |                                  S r%   r&   r(   s    r   r*   zToolCall.to_openai   r+   r   	tool_callc                 v    t          |          }|                    dd            |                     |          S )Nindex)r   popr.   )r/   rB   openai_tool_calls      r   r0   zToolCall.from_openai   s;      	??Wd+++!!"2333r   N)r   r   r   r   r@   r   r   r   r   r"   r3   r   r   r*   r1   r0   r   r   r   r>   r>      s          " B(D)(((!4S> ! ! ! ! 4DcN 4z 4 4 4 [4 4 4r   r>   ToolType)bound)r:   enumr   typingr   r   pydanticr   mistral_common.baser   r	   r   r   r   r!   r3   r>   rG   r   r   r   <module>rM      sy                  $ $ $ $ $ $ + + + + + +    {   >
 
 
 
 
T 
 
 
    d   "#/ #/ #/ #/ #/; #/ #/ #/L    ;   @4 4 4 4 4{ 4 4 4B 7:T***r   