a
    bg                     @   sX   d dl 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 deZdS )	    N)Optional)CallbackManagerForToolRun)BaseTool)
ConfigDict)GraphQLAPIWrapperc                   @   sT   e Zd ZU dZeed< dZeed< dZeed< e	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 }} }}    descriptionT)Zarbitrary_types_allowedN)
tool_inputrun_managerreturnc                 C   s   | j |}tj|ddS )N   )indent)r   runjsondumps)selfr   r   result r   t/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/tools/graphql/tool.py_run   s    zBaseGraphQLTool._run)N)__name__
__module____qualname____doc__r   __annotations__r	   strr
   r   Zmodel_configr   r   r   r   r   r   r   r      s   
	 r   )r   typingr   Zlangchain_core.callbacksr   Zlangchain_core.toolsr   Zpydanticr   Z%langchain_community.utilities.graphqlr   r   r   r   r   r   <module>   s   