
    {h                     f    d dl mZmZmZ d dlmZmZ d dlmZ d dl	m
Z
  G d de      Z d        Zy)	    )OptionalTypeget_args)ABCabstractmethod)	BaseModelBaseIOSchemac                   :    e Zd ZU dZdZee   ed<   dZee   ed<   y)BaseToolConfigz
    Configuration for a tool.

    Attributes:
        title (Optional[str]): Overrides the default title of the tool.
        description (Optional[str]): Overrides the default description of the tool.
    Ntitledescription)	__name__
__module____qualname____doc__r   r   str__annotations__r        ]/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/atomic_agents/base/base_tool.pyr   r      s%      E8C=!%K#%r   r   c                  R    d d xdd xf G fdd
} t         |       S )InputSchemac                      t         S Nr	   r   r   r   r   r      s    L(r   OutputSchemac                      t         S r   r	   r   r   r   r   r      s    *Dr   c                       e Zd ZW  ZdZ e       fdefdZedeW    fd       Z	edeW    fd       Z
edefd       Zedefd       Zed	W dW fd
       Zy)BaseToolaX  
    Base class for tools within the Atomic Agents framework.

    Tools enable agents to perform specific tasks by providing a standardized interface
    for input and output. Each tool is defined with specific input and output schemas
    that enforce type safety and provide documentation.

    Type Parameters:
        InputSchema: Schema defining the input data, must be a subclass of BaseIOSchema.
        OutputSchema: Schema defining the output data, must be a subclass of BaseIOSchema.

    Attributes:
        config (BaseToolConfig): Configuration for the tool, including optional title and description overrides.
        input_schema (Type[InputSchema]): Schema class defining the input data (derived from generic type parameter).
        output_schema (Type[OutputSchema]): Schema class defining the output data (derived from generic type parameter).
        tool_name (str): The name of the tool, derived from the input schema's title or overridden by the config.
        tool_description (str): Description of the tool, derived from the input schema's description or overridden by the config.
    configc                     || _         y)z
        Initializes the BaseTool with an optional configuration override.

        Args:
            config (BaseToolConfig, optional): Configuration for the tool, including optional title and description overrides.
        N)r    )selfr    s     r   __init__zBaseTool.__init__)   s     r   returnc                 ^    t        | d      rt        | j                        \  }}|S t        }|S )z
        Returns the input schema class for the tool.

        Returns:
            Type[InputSchema]: The input schema class.
        __orig_class__hasattrr   r&   r
   )r"   TI_s      r   input_schemazBaseTool.input_schema2   s6     4)*T001EB 	 B	r   c                 ^    t        | d      rt        | j                        \  }}|S t        }|S )z
        Returns the output schema class for the tool.

        Returns:
            Type[OutputSchema]: The output schema class.
        r&   r'   )r"   r*   TOs      r   output_schemazBaseTool.output_schemaA   s6     4)*T001EAr 	 B	r   c                 l    | j                   j                  xs | j                  j                         d   S )zh
        Returns the name of the tool.

        Returns:
            str: The name of the tool.
        r   )r    r   r+   model_json_schemar"   s    r   	tool_namezBaseTool.tool_nameP   s-     {{  RD$5$5$G$G$I'$RRr   c                 l    | j                   j                  xs | j                  j                         d   S )zv
        Returns the description of the tool.

        Returns:
            str: The description of the tool.
        r   )r    r   r+   r0   r1   s    r   tool_descriptionzBaseTool.tool_descriptionZ   s.     {{&&^$*;*;*M*M*OP]*^^r   paramsc                      y)ax  
        Executes the tool with the provided parameters.

        Args:
            params (InputSchema): Input parameters adhering to the input schema.

        Returns:
            OutputSchema: Output resulting from executing the tool, adhering to the output schema.

        Raises:
            NotImplementedError: If the method is not implemented by a subclass.
        Nr   )r"   r5   s     r   runzBaseTool.rund   s     	r   N)r   r   r   __type_params__r   r   r#   propertyr   r+   r.   r   r2   r4   r   r7   ).type_paramsr   r   s   r   r   r      s    & 1?0@ ~  d;/   tL1   S3 S S _# _ _ + ,  r   r   )r   ).generic_baser:   r   r   s    @@@r    <generic parameters of BaseTool>r<      s     (*D( ] ]c ]r   N)typingr   r   r   abcr   r   pydanticr   !atomic_agents.base.base_io_schemar
   r   r   r   r   r   <module>rA      s,    + + #  :
&Y 
&] ]r   