U
    h}                     @   sL   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ G dd deZ	dS )    N)Optional)CallbackManagerForToolRun)BaseTool)GraphQLAPIWrapperc                   @   sX   e Zd ZU dZeed< dZeed< dZeed< G dd dZ	dee
e ed
ddZd	S )BaseGraphQLToolz%Base tool for querying a GraphQL API.graphql_wrapperZquery_graphqlnamea      Input to this tool is a detailed and correct GraphQL query, output is a result from the API.
    If the query is not correct, an error message will be returned.
    If an error is returned with 'Bad request' in it, rewrite the query and try again.
    If an error is returned with 'Unauthorized' in it, do not try again, but tell the user to change their authentication.

    Example Input: query {{ allUsers {{ id, name, email }} }}    descriptionc                   @   s   e Zd ZdZdS )zBaseGraphQLTool.ConfigTN)__name__
__module____qualname__Zarbitrary_types_allowed r   r   J/tmp/pip-unpacked-wheel-9gdii04g/langchain_community/tools/graphql/tool.pyConfig   s   r   N)
tool_inputrun_managerreturnc                 C   s   | j |}tj|ddS )N   )indent)r   runjsondumps)selfr   r   resultr   r   r   _run   s    zBaseGraphQLTool._run)N)r
   r   r   __doc__r   __annotations__r   strr	   r   r   r   r   r   r   r   r   r   
   s   
	 r   )
r   typingr   Zlangchain_core.callbacksr   Zlangchain_core.toolsr   Z%langchain_community.utilities.graphqlr   r   r   r   r   r   <module>   s
   