Ë
    µŒj¿  ã                   ó‚   — d dl mZmZmZmZmZ 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«      Z G d	„ d
e
«      Zy)é    )ÚAnyÚDictÚListÚMappingÚOptionalN)ÚCallbackManagerForLLMRun)ÚLLM)Ú
ConfigDict)Úenforce_stop_tokensc            	       ó\   — e Zd ZdZededeeef   deeef   fd„«       Zededefd„«       Z	y)	ÚContentHandlerAmazonAPIGatewayzµAdapter to prepare the inputs from Langchain to a format
    that LLM model expects.

    It also provides helper function to extract
    the generated text from the model response.ÚpromptÚmodel_kwargsÚreturnc                 ó   — ||dœS )N)ÚinputsÚ
parameters© )Úclsr   r   s      úu/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/amazon_api_gateway.pyÚtransform_inputz.ContentHandlerAmazonAPIGateway.transform_input   s   € ð !°Ñ=Ð=ó    Úresponsec                 ó.   — |j                  «       d   d   S )Nr   Úgenerated_text)Újson)r   r   s     r   Útransform_outputz/ContentHandlerAmazonAPIGateway.transform_output   s   € à�}‰}‹˜qÑ!Ð"2Ñ3Ð3r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚclassmethodÚstrr   r   r   r   r   r   r   r   r      se   „ ñ3ð ð>Øð>Ø(,¨S°#¨X©ð>à	ˆc�3ˆh‰ò>ó ð>ð
 ð4¨ð 4°ò 4ó ñ4r   r   c                   óà   — e Zd ZU dZeed<   	 dZee   ed<   	 dZ	ee   ed<   	  e
«       Ze
ed<   	  ed¬«      Zed	eeef   fd
„«       Zed	efd„«       Z	 	 ddedeee      dee   ded	ef
d„Zy)ÚAmazonAPIGatewayz6Amazon API Gateway to access LLM models hosted on AWS.Úapi_urlNÚheadersr   Úcontent_handlerÚforbid)Úextrar   c                 ó`   — | j                   xs i }i | j                  | j                  dœ¥d|i¥S )zGet the identifying parameters.)r&   r'   r   )r   r&   r'   )ÚselfÚ_model_kwargss     r   Ú_identifying_paramsz$AmazonAPIGateway._identifying_params3   s@   € ð ×)Ñ)Ò/¨Rˆð
ØŸ,™,°4·<±<Ñ@ð
à˜}Ð-ð
ð 	
r   c                  ó   — y)zReturn type of llm.Úamazon_api_gatewayr   )r,   s    r   Ú	_llm_typezAmazonAPIGateway._llm_type<   s   € ð $r   r   ÚstopÚrun_managerÚkwargsc                 óH  — | j                   xs i }| j                  j                  ||«      }	 t        j                  | j
                  | j                  |¬«      }| j                  j                  |«      }|�t        ||«      }|S # t        $ r}	t        d|	› �«      ‚d}	~	ww xY w)ab  Call out to Amazon API Gateway model.

        Args:
            prompt: The prompt to pass into the model.
            stop: Optional list of stop words to use when generating.

        Returns:
            The string generated by the model.

        Example:
            .. code-block:: python

                response = se("Tell me a joke.")
        )r'   r   zError raised by the service: N)r   r(   r   ÚrequestsÚpostr&   r'   r   Ú	ExceptionÚ
ValueErrorr   )
r,   r   r2   r3   r4   r-   Úpayloadr   ÚtextÚerrors
             r   Ú_callzAmazonAPIGateway._callA   s©   € ð* ×)Ñ)Ò/¨RˆØ×&Ñ&×6Ñ6°v¸}ÓMˆð		FÜ—}‘}Ø—‘ØŸ™ØôˆHð
 ×'Ñ'×8Ñ8¸ÓBˆDð
 ÐÜ& t¨TÓ2ˆDàˆøô ò 	FÜÐ<¸U¸GÐDÓEÐEûð	Fús   ®AB Â	B!ÂBÂB!)NN)r   r   r    r!   r#   Ú__annotations__r'   r   r   r   r   r(   r
   Úmodel_configÚpropertyr   r   r.   r1   r   r   r=   r   r   r   r%   r%      sÜ   … Ù@àƒLØà"€GˆX�d‰^Ó"ØCà#'€L�(˜4‘.Ó'Ø1á6TÓ6V€OÐ3ÓVðñ
 Øô€Lð ð
 W¨S°#¨XÑ%6ò 
ó ð
ð ð$˜3ò $ó ð$ð %)Ø:>ñ	&àð&ð �t˜C‘yÑ!ð&ð Ð6Ñ7ð	&ð
 ð&ð 
ô&r   r%   )Útypingr   r   r   r   r   r6   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úpydanticr
   Úlangchain_community.llms.utilsr   r   r%   r   r   r   Ú<module>rF      s2   ðß 5Õ 5ã Ý =Ý 3Ý å >÷4ñ 4ô$J�sõ Jr   