§
    šŠtj{
  ã                  óŠ   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ  G d
„ de	¦  «        ZdS )zHTool for interacting with a single API with natural language definition.é    )Úannotations)ÚAnyÚOptional)ÚBaseLanguageModel)ÚTool)ÚOpenAPIEndpointChain)ÚAPIOperation)ÚOpenAPISpec)ÚRequestsc                  óJ   — e Zd ZdZedd„¦   «         Ze	 	 	 ddd„¦   «         Zd	S )ÚNLAToolzNatural Language API Tool.Úchainr   Ú	api_titleÚstrÚreturnú	'NLATool'c                ó–   — |                      dd¦  «        › d|j        j        › �}d|› d|j        j        › �} | ||j        |¬¦  «        S )zÓConvert an endpoint chain to an API endpoint tool.

        Args:
            chain: The endpoint chain.
            api_title: The title of the API.

        Returns:
            The API endpoint tool.
        ú Ú_ú.zI'm an AI from zG. Instruct what you want, and I'll assist via an API with description: )ÚnameÚfuncÚdescription)ÚreplaceÚapi_operationÚoperation_idr   Úrun)Úclsr   r   Úexpanded_namer   s        úi/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/agent_toolkits/nla/tool.pyÚfrom_open_api_endpoint_chainz$NLATool.from_open_api_endpoint_chain   st   € ð × Ò   cÑ*Ô*ÐOÐO¨UÔ-@Ô-MÐOÐOð 	ð2˜ið 2ð 2àÔ#Ô/ð2ð 2ð 	ð
 ˆs˜¨E¬IÀ;ÐOÑOÔOÐOó    NFÚllmr   ÚpathÚmethodÚspecr
   ÚrequestsúOptional[Requests]ÚverboseÚboolÚreturn_intermediate_stepsÚkwargsr   c                óœ   — t          j        |||¦  «        }	t          j        |	|f|||dœ|¤Ž}
|                      |
|j        j        ¦  «        S )a<  Instantiate the tool from the specified path and method.

        Args:
            llm: The language model to use.
            path: The path of the API.
            method: The method of the API.
            spec: The OpenAPI spec.
            requests: Optional requests object. Default is None.
            verbose: Whether to print verbose output. Default is False.
            return_intermediate_steps: Whether to return intermediate steps.
                Default is False.
            kwargs: Additional arguments.

        Returns:
            The tool.
        )r'   r)   r+   )r	   Úfrom_openapi_specr   Úfrom_api_operationr!   ÚinfoÚtitle)r   r#   r$   r%   r&   r'   r)   r+   r,   r   r   s              r    Úfrom_llm_and_methodzNLATool.from_llm_and_method*   sk   € õ8 %Ô6°t¸TÀ6ÑJÔJˆÝ$Ô7ØØð
ð ØØ&?ð
ð 
ð ð
ð 
ˆð ×/Ò/°°t´y´ÑGÔGÐGr"   )r   r   r   r   r   r   )NFF)r#   r   r$   r   r%   r   r&   r
   r'   r(   r)   r*   r+   r*   r,   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr!   r2   © r"   r    r   r      ss   € € € € € Ø$Ð$àðPð Pð Pñ „[ðPð, ð (,ØØ*/ð$Hð $Hð $Hð $Hñ „[ð$Hð $Hð $Hr"   r   N)r6   Ú
__future__r   Útypingr   r   Úlangchain_core.language_modelsr   Úlangchain_core.toolsr   Ú(langchain_community.chains.openapi.chainr   Ú2langchain_community.tools.openapi.utils.api_modelsr	   Ú5langchain_community.tools.openapi.utils.openapi_utilsr
   Ú&langchain_community.utilities.requestsr   r   r8   r"   r    ú<module>rA      sß   ðØ NÐ Nà "Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à <Ð <Ð <Ð <Ð <Ð <Ø %Ð %Ð %Ð %Ð %Ð %à IÐ IÐ IÐ IÐ IÐ IØ KÐ KÐ KÐ KÐ KÐ KØ MÐ MÐ MÐ MÐ MÐ MØ ;Ð ;Ð ;Ð ;Ð ;Ð ;ð?Hð ?Hð ?Hð ?Hð ?Hˆdñ ?Hô ?Hð ?Hð ?Hð ?Hr"   