
    dhD                        S SK Jr  S SKrS SKJrJr  S SKrS SKrS SKJ	r	J
r
  S SKJr  S SKJr   " S S\5      r " S	 S
\5      rSS jr " S S\5      r " S S\5      rg)    )annotationsN)OptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)	BaseModelc                  <    \ rS rSr% SrS\S'   S\S'   SrS\S'   S	rg
)	ApiConfig   zAPI Configuration.strtypeurlFzOptional[bool]has_user_authentication N)__name__
__module____qualname____firstlineno____doc____annotations__r   __static_attributes__r       X/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/plugin.pyr   r      s    
I	H.3^3r   r   c                      \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S\S'   S	rS
\S'   S\S'   S\S'   S\S'   S\S'   \SS j5       rSr	g	)AIPlugin   z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                Z    [         R                  " U5      R                  5       nU " S0 UD6$ )z Instantiate AIPlugin from a URL.r   )requestsgetjson)clsr   responses      r   from_urlAIPlugin.from_url&   s'     <<$))+Xr   r   )r   r   returnr   )
r   r   r   r   r   r   r#   classmethodr/   r   r   r   r   r   r      sV    D.	N  !! r   r   c                     [         R                  " U 5      $ ! [         R                   a    [        R                  " U 5      s $ f = f)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_specr9   -   s9    #zz# #~~c""#s    *AAc                  (    \ rS rSr% SrSrS\S'   Srg)AIPluginToolSchema<   zSchema for AIPluginTool. r%   
tool_inputr   N)r   r   r   r   r   r>   r   r   r   r   r   r;   r;   <   s    " "J"r   r;   c                      \ rS rSr% SrS\S'   S\S'   \rS\S'   \SS	 j5       r	  S     SS jjr
  S     SS jjrSrg
)AIPluginToolB   z3Tool for getting the OpenAPI spec for an AI Plugin.r   pluginr   api_speczType[AIPluginToolSchema]args_schemac                H   [         R                  U5      nSUR                   SUR                   S3UR                  -   n[        R
                  " UR                  R                  5      R                  n[        U5      nSUR                   SU 3nU " UR                  UUUS9$ )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descriptionrB   rC   )r   r/   r    r"   r*   r+   r$   r   textr9   r!   r   )r-   r   rB   rG   open_api_spec_stropen_api_specrC   s          r   from_plugin_urlAIPluginTool.from_plugin_urlI   s    ""3'((.(=(='> ?;$$%%68 (() %LL8==$%67F889 :*O- 	
 &&#	
 	
r   Nc                    U R                   $ )zUse the tool.rC   selfr>   run_managers      r   _runAIPluginTool._run`   s     }}r   c                "   #    U R                   $ 7f)zUse the tool asynchronously.rN   rO   s      r   _arunAIPluginTool._arunh   s      }}s   r   )r   r   r1   r@   )r=   N)r>   r%   rQ   z#Optional[CallbackManagerForToolRun]r1   r   )NN)r>   r%   rQ   z(Optional[AsyncCallbackManagerForToolRun]r1   r   )r   r   r   r   r   r   r;   rD   r2   rK   rR   rU   r   r   r   r   r@   r@   B   s    =M,>K)>
 
0 %';?! 9 
	 %)@D! > 
	 r   r@   )r8   r   r1   dict)
__future__r   r,   typingr   r   r*   r6   langchain_core.callbacksr   r   langchain_core.toolsr   pydanticr	   r   r   r9   r;   r@   r   r   r   <module>r]      sV    "  !   * 4	 4y *## #,8 ,r   