Ë
    µŒj{
  ã                  ó‚   — 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y)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y)ÚNLAToolzNatural Language API Tool.c                óº   — |j                  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)ÚclsÚchainÚ	api_titleÚexpanded_namer   s        úu/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/agent_toolkits/nla/tool.pyÚfrom_open_api_endpoint_chainz$NLATool.from_open_api_endpoint_chain   sq   € ð × Ñ   cÓ*Ð+¨1¨U×-@Ñ-@×-MÑ-MÐ,NÐOð 	ð ˜i˜[ð )à×#Ñ#×/Ñ/Ð0ð2ð 	ñ
 ˜¨E¯I©IÀ;ÔOÐOó    Nc                ó²   — t        j                  |||«      }	t        j                  |	|f|||dœ|¤Ž}
| j	                  |
|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.
        )ÚrequestsÚverboseÚreturn_intermediate_steps)r	   Úfrom_openapi_specr   Úfrom_api_operationr   ÚinfoÚtitle)r   ÚllmÚpathÚmethodÚspecr!   r"   r#   Úkwargsr   r   s              r   Úfrom_llm_and_methodzNLATool.from_llm_and_method*   se   € ô8 %×6Ñ6°t¸TÀ6ÓJˆÜ$×7Ñ7ØØð
ð ØØ&?ñ
ð ñ
ˆð ×/Ñ/°°t·y±y·±ÓGÐGr   )r   r   r   ÚstrÚreturnú	'NLATool')NFF)r(   r   r)   r.   r*   r.   r+   r
   r!   zOptional[Requests]r"   Úboolr#   r1   r,   r   r/   r0   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r-   © r   r   r   r      s¶   „ Ù$àðPØ(ðPØ58ðPà	òPó ðPð, ð (,ØØ*/ð$Hàð$Hð ð$Hð ð	$Hð
 ð$Hð %ð$Hð ð$Hð $(ð$Hð ð$Hð 
ò$Hó ñ$Hr   r   N)r5   Ú
__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   r7   r   r   Ú<module>r@      s.   ðÙ Nå "ç  å <Ý %å IÝ KÝ MÝ ;ô?Hˆdõ ?Hr   