o
    i                     @   sf   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 deZG dd	 d	Zd
S )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                   @   s   e Zd ZdZdZdZdS )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 r   r   Y/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/adapters/schemas/tools_schema.pyr
      s    r
   c                   @   s   e Zd ZdZ	ddeeeB  deee	eee
ef  f  ddfddZedee fdd	Zedee	eee
ef  f fd
dZejdee	eee
ef  f ddfddZdS )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                 C   s   dd }||| _ || _dS )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                 S   sX   g }| D ]%}t |tr|| qt|r!t|}||  qtdt| |S )NzUnsupported tool type: )
isinstancer	   appendcallabler   to_function_schema	TypeErrortype)toolsschemastoolwrapperr   r   r   _map_standard_tools6   s   
z1ToolsSchema.__init__.<locals>._map_standard_toolsN)_standard_tools_custom_tools)selfr   r   r#   r   r   r   __init__)   s   

zToolsSchema.__init__c                 C      | j S )zGet the list of standard function schema tools.

        Returns:
            List of tools following the FunctionSchema format.
        )r$   r&   r   r   r   r   E      zToolsSchema.standard_toolsc                 C   r(   )zGet the custom tools dictionary.

        Returns:
            Dictionary mapping adapter types to their custom tool definitions.
        r%   r)   r   r   r   r   N   r*   zToolsSchema.custom_toolsvaluec                 C   s
   || _ dS )zSet the custom tools dictionary.

        Args:
            value: Dictionary mapping adapter types to their custom tool definitions.
        Nr+   )r&   r,   r   r   r   r   W   s   
)N)r   r   r   r   r   r	   r   r   r   r
   strr   r'   propertyr   r   setterr   r   r   r   r   !   s     


$,r   N)r   enumr   typingr   r   r   r   (pipecat.adapters.schemas.direct_functionr   r   (pipecat.adapters.schemas.function_schemar	   r
   r   r   r   r   r   <module>   s   