
    dh-	                     N    S r SSKrSSKJrJrJr  SSKJrJrJ	r	   " S S\5      r
g)zUtil that calls Lambda.    N)AnyDictOptional)	BaseModel
ConfigDictmodel_validatorc                       \ rS rSr% SrSr\\S'    Sr\	\
   \S'    Sr\	\
   \S'    Sr\	\
   \S'    \" SS	9r\" S
S9\S\S\4S j5       5       rS\
S\
4S jrSrg)LambdaWrapper	   a  Wrapper for AWS Lambda SDK.
To use, you should have the ``boto3`` package installed
and a lambda functions built from the AWS Console or
CLI. Set up your AWS credentials with ``aws configure``

Example:
    .. code-block:: bash

        pip install boto3

        aws configure

Nlambda_clientfunction_nameawslambda_tool_nameawslambda_tool_descriptionforbid)extrabefore)modevaluesreturnc                 j     SSK nUR                  S5      US'   U$ ! [         a    [        S5      ef = f)z3Validate that python package exists in environment.r   NzBboto3 is not installed. Please install it with `pip install boto3`lambdar   )boto3ImportErrorclient)clsr   r   s      _/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/awslambda.pyvalidate_environment"LambdaWrapper.validate_environment%   sE    
	 #(,,x"8  	T 	s    2queryc                 2   U R                   R                  U R                  S[        R                  " SU05      S9n US   nUR                  5       R                  S5      n[        R                  " U5      S   nUb  US:X  a  gS	U 3$ ! [         a     gf = f)
z
Invokes the lambda function and returns the
result.

Args:
    query: an input to passed to the lambda
        function as the ``body`` of a JSON
        object.
RequestResponsebody)FunctionNameInvocationTypePayloadr%   zutf-8z$Failed to parse response from Lambda zRequest failed.zResult: )	r   invoker   jsondumpsreaddecodeloadsStopIteration)selfr   respayload_streampayload_stringanswers         r   runLambdaWrapper.run5   s       ''++,JJ/ ( 
	: ^N+00299'BNZZ/7F
 >Vr\$fX&&  	:9	:s   =B	 	
BB )__name__
__module____qualname____firstlineno____doc__r   r   __annotations__r   r   strr   r   r   model_configr   classmethodr   r   r3   __static_attributes__r5       r   r
   r
   	   s     M3%#'M8C='*)-#-9044;L (#$ 3   $' ' 'r@   r
   )r:   r(   typingr   r   r   pydanticr   r   r   r
   r5   r@   r   <module>rC      s%      & & ; ;H'I H'r@   