
    qi                     r    d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
 ddlmZ  G d de      Z G d d	      Zy
)zTools schema definitions for function calling adapters.

This module provides schemas for managing both standardized function tools
and custom adapter-specific tools in the Pipecat framework.
    )Enum)AnyDictListOptional)DirectFunctionDirectFunctionWrapper)FunctionSchemac                       e Zd ZdZdZdZy)AdapterTypea8  Supported adapter types for custom tools.

    Parameters:
        GEMINI: Google Gemini adapter - currently the only service supporting custom tools.
        SHIM: Backward compatibility shim for creating ToolsSchemas from lists of tools in
              any format, used by LLMContext.from_openai_context.
    geminishimN)__name__
__module____qualname____doc__GEMINISHIM     W/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/adapters/schemas/tools_schema.pyr   r      s     FDr   r   c                       e Zd ZdZ	 ddeeez     deee	eee
ef      f      ddfdZedee   fd       Zedee	eee
ef      f   fd       Zej                   d	ee	eee
ef      f   ddfd
       Zy)ToolsSchemaa  Schema for managing both standard and custom function calling tools.

    This class provides a unified interface for handling standardized function
    schemas alongside custom tools that may not follow the standard format,
    such as adapter-specific search tools.
    Nstandard_toolscustom_toolsreturnc                 2    d } ||      | _         || _        y)aG  Initialize the tools schema.

        Args:
            standard_tools: List of tools following the standardized FunctionSchema format.
            custom_tools: Dictionary mapping adapter types to their custom tool definitions.
                These tools may not follow the FunctionSchema format (e.g., search_tool).
        c                     g }| D ]p  }t        |t              r|j                  |       %t        |      r+t	        |      }|j                  |j                                [t        dt        |              |S )NzUnsupported tool type: )
isinstancer
   appendcallabler	   to_function_schema	TypeErrortype)toolsschemastoolwrappers       r   _map_standard_toolsz1ToolsSchema.__init__.<locals>._map_standard_tools6   sr    G LdN3NN4(d^3D9GNN7#=#=#?@#&=d4j\$JKKL Nr   N)_standard_tools_custom_tools)selfr   r   r)   s       r   __init__zToolsSchema.__init__)   s    
	  3>B)r   c                     | j                   S )zGet the list of standard function schema tools.

        Returns:
            List of tools following the FunctionSchema format.
        )r*   r,   s    r   r   zToolsSchema.standard_toolsE   s     ###r   c                     | j                   S )zGet the custom tools dictionary.

        Returns:
            Dictionary mapping adapter types to their custom tool definitions.
        r+   r/   s    r   r   zToolsSchema.custom_toolsN   s     !!!r   valuec                     || _         y)zSet the custom tools dictionary.

        Args:
            value: Dictionary mapping adapter types to their custom tool definitions.
        Nr1   )r,   r2   s     r   r   zToolsSchema.custom_toolsW   s     #r   )N)r   r   r   r   r   r
   r   r   r   r   strr   r-   propertyr   r   setterr   r   r   r   r   !   s     KO*^n<=* tKd38n1E$EFG* 
	*8 $^ 4 $ $ "d;T#s(^0D#DE " " #${Dc3h4H'H"I #d # #r   r   N)r   enumr   typingr   r   r   r   (pipecat.adapters.schemas.direct_functionr   r	   (pipecat.adapters.schemas.function_schemar
   r   r   r   r   r   <module>r;      s1     , , Z C
$ 
=# =#r   