
    7|hh                        d dl mZ d dlZd dlmZmZ d dlZd dlZd dlm	Z	m
Z
 d dlmZ d dlmZ  G d de      Z G d	 d
e      ZddZ G d de      Z G d de      Zy)    )annotationsN)OptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)	BaseModelc                  4    e Zd ZU dZded<   ded<   dZded<   y)		ApiConfigzAPI Configuration.strtypeurlFzOptional[bool]has_user_authenticationN)__name__
__module____qualname____doc____annotations__r        _/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/tools/plugin.pyr   r      s    
I	H.3^3r   r   c                      e Zd ZU dZded<   ded<   ded<   ded<   ded<   dZd	ed
<   ded<   ded<   ded<   ded<   edd       Zy)AIPluginzAI Plugin Definition.r   schema_versionname_for_modelname_for_humandescription_for_modeldescription_for_humanNzOptional[dict]authr   apiOptional[str]logo_urlcontact_emaillegal_info_urlc                X    t        j                  |      j                         } | di |S )z Instantiate AIPlugin from a URL.r   )requestsgetjson)clsr   responses      r   from_urlzAIPlugin.from_url&   s'     <<$))+Xr   )r   r   returnr   )r   r   r   r   r   r   classmethodr+   r   r   r   r   r      sV    D.	N  !! r   r   c                    	 t        j                  |       S # t         j                  $ r t        j                  |       cY S w xY w)zConvert the yaml or json serialized spec to a dict.

    Args:
        txt: The yaml or json serialized spec.

    Returns:
        dict: The spec as a dict.
    )r(   loadsJSONDecodeErroryaml	safe_load)txts    r   marshal_specr4   -   s9    #zz# #~~c""#s    (AAc                       e Zd ZU dZdZded<   y)AIPluginToolSchemazSchema for AIPluginTool. r!   
tool_inputN)r   r   r   r   r8   r   r   r   r   r6   r6   <   s    " "J"r   r6   c                  v    e Zd ZU dZded<   ded<   eZded<   edd       Z	 	 d	 	 	 	 	 dd
Z		 	 d	 	 	 	 	 ddZ
y	)AIPluginToolz3Tool for getting the OpenAPI spec for an AI Plugin.r   pluginr   api_speczType[AIPluginToolSchema]args_schemac                L   t         j                  |      }d|j                   d|j                   d|j                  z   }t	        j
                  |j                  j                        j                  }t        |      }d|j                   d| } | |j                  |||      S )NzRCall this tool to get the OpenAPI spec (and usage guide) for interacting with the z2 API. You should only call this ONCE! What is the z API useful for? zUsage Guide: z

OpenAPI Spec: )namedescriptionr;   r<   )r   r+   r   r   r&   r'   r    r   textr4   r   r   )r)   r   r;   r@   open_api_spec_stropen_api_specr<   s          r   from_plugin_urlzAIPluginTool.from_plugin_urlI   s    ""3'((.(=(='> ?;$$%%68 (() %LL8==$%67F889 :*O- 	
 &&#	
 	
r   Nc                    | j                   S )zUse the tool.r<   selfr8   run_managers      r   _runzAIPluginTool._run`   s     }}r   c                "   K   | j                   S w)zUse the tool asynchronously.rF   rG   s      r   _arunzAIPluginTool._arunh   s      }}s   )r   r   r,   r:   )r7   N)r8   r!   rI   z#Optional[CallbackManagerForToolRun]r,   r   )NN)r8   r!   rI   z(Optional[AsyncCallbackManagerForToolRun]r,   r   )r   r   r   r   r   r6   r=   r-   rD   rJ   rL   r   r   r   r:   r:   B   s    =M,>K)>
 
0 %';?! 9 
	 %)@D! > 
	r   r:   )r3   r   r,   dict)
__future__r   r(   typingr   r   r&   r1   langchain_core.callbacksr   r   langchain_core.toolsr   pydanticr	   r   r   r4   r6   r:   r   r   r   <module>rS      sV    "  !   * 4	 4y *## #,8 ,r   