
    dh{
                        S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr   " S
 S\	5      rg)zHTool for interacting with a single API with natural language definition.    )annotations)AnyOptional)BaseLanguageModel)Tool)OpenAPIEndpointChain)APIOperation)OpenAPISpec)Requestsc                  x    \ rS rSrSr\      SS j5       r\   S                 S	S jj5       rSrg)
NLATool   zNatural Language API Tool.c                    UR                  SS5       SUR                  R                   3nSU SUR                  R                   3nU " X1R                  US9$ )zConvert 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        c/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/agent_toolkits/nla/tool.pyfrom_open_api_endpoint_chain$NLATool.from_open_api_endpoint_chain   so       c*+1U-@-@-M-M,NO 	 i[ )##//02 	
 II;OO    Nc                    [         R                  " XBU5      n	[        R                  " U	U4UUUS.UD6n
U R	                  XR
                  R                  5      $ )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_methodNLATool.from_llm_and_method*   sa    8 %66t6J$77
 &?
 
 //yyGGr!    )r   r   r   strreturn	'NLATool')NFF)r*   r   r+   r2   r,   r2   r-   r
   r#   zOptional[Requests]r$   boolr%   r5   r.   r   r3   r4   )	__name__
__module____qualname____firstlineno____doc__classmethodr   r/   __static_attributes__r1   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)r:   
__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   r1   r!   r   <module>rE      s.    N "   < % I K M ;?Hd ?Hr!   