Ë
    µŒ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mZ d dlmZmZmZ d dlmZ  G d„ d	e
«      Zy)
é    )ÚAnyÚDictÚListÚMappingÚOptionalN)ÚCallbackManagerForLLMRun)ÚLLM©Úconvert_to_secret_strÚget_from_dict_or_env)Ú
ConfigDictÚ	SecretStrÚmodel_validator)Úenforce_stop_tokensc                   ó`  — e Zd ZU dZdZeed<   	 dZeed<   	 dZ	e
ed<   	 dZeed	<   	 d
Ze
ed<   	 dZe
ed<   	 eed<   dZee   ed<   	  ed¬«      Z ed¬«      ededefd„«       «       Zedeeef   f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)!ÚForefrontAIa2  ForefrontAI large language models.

    To use, you should have the environment variable ``FOREFRONTAI_API_KEY``
    set with your API key.

    Example:
        .. code-block:: python

            from langchain_community.llms import ForefrontAI
            forefrontai = ForefrontAI(endpoint_url="")
    Ú Úendpoint_urlgffffffæ?Útemperatureé   Úlengthg      ð?Útop_pé(   Útop_ké   Úrepetition_penaltyÚforefrontai_api_keyNÚbase_urlÚforbid)ÚextraÚbefore)ÚmodeÚvaluesÚreturnc                 ó8   — t        t        |dd«      «      |d<   |S )z,Validate that api key exists in environment.r   ÚFOREFRONTAI_API_KEYr
   )Úclsr#   s     ún/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/forefrontai.pyÚvalidate_environmentz ForefrontAI.validate_environment5   s)   € ô )>Ü  Ð)>Ð@UÓVó)
ˆÐ$Ñ%ð ˆó    c                 óv   — | j                   | j                  | j                  | j                  | j                  dœS )z7Get the default parameters for calling ForefrontAI API.©r   r   r   r   r   r,   ©Úselfs    r(   Ú_default_paramszForefrontAI._default_params>   s5   € ð  ×+Ñ+Ø—k‘kØ—Z‘ZØ—Z‘ZØ"&×"9Ñ"9ñ
ð 	
r*   c                 ó:   — i d| j                   i¥| j                  ¥S )zGet the identifying parameters.r   )r   r/   r-   s    r(   Ú_identifying_paramszForefrontAI._identifying_paramsI   s&   € ð O�> 4×#4Ñ#4Ð5ÐN¸×9MÑ9MÐNÐNr*   c                  ó   — y)zReturn type of llm.Úforefrontai© r-   s    r(   Ú	_llm_typezForefrontAI._llm_typeN   s   € ð r*   ÚpromptÚstopÚrun_managerÚkwargsc                 óü   — d| j                   j                  «       › �}t        j                  | j                  |ddœd|i| j
                  ¥|¥¬«      }|j                  «       }|d   d   d   }|�t        ||«      }|S )	ar  Call out to ForefrontAI's complete endpoint.

        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 = ForefrontAI("Tell me a joke.")
        zBearer zapplication/json)ÚAuthorizationzContent-TypeÚtext)ÚurlÚheadersÚjsonÚresultr   Ú
completion)r   Úget_secret_valueÚrequestsÚpostr   r/   r?   r   )	r.   r6   r7   r8   r9   Ú
auth_valueÚresponseÚresponse_jsonr<   s	            r(   Ú_callzForefrontAI._callS   s–   € ð* ˜t×7Ñ7×HÑHÓJÐKÐLˆ
Ü—=‘=Ø×!Ñ!à!+Ø 2ñð ˜&ÐC D×$8Ñ$8ÐC¸FÐCô
ˆð !Ÿ™›ˆØ˜XÑ& qÑ)¨,Ñ7ˆØÐô ' t¨TÓ2ˆDØˆr*   )NN) Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚstrÚ__annotations__r   Úfloatr   Úintr   r   r   r   r   r   r   Úmodel_configr   Úclassmethodr   r   r)   Úpropertyr   r/   r1   r5   r   r   rH   r4   r*   r(   r   r      s`  … ñ
ð €L�#ÓØà€K�ÓØ+à€FˆCÓØEà€Eˆ5ÓØDà€Eˆ3ƒOð!ð  Ð˜ÓØ;à"Ó"à"€Hˆh�s‰mÓ"Ø?áØô€Lñ ˜(Ô#Øð¨$ð °3ò ó ó $ðð ð
 ¨¨c¨Ñ!2ò 
ó ð
ð ðO W¨S°#¨XÑ%6ò Oó ðOð ð˜3ò ó ðð %)Ø:>ñ	$àð$ð �t˜C‘yÑ!ð$ð Ð6Ñ7ð	$ð
 ð$ð 
ô$r*   r   )Útypingr   r   r   r   r   rC   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úlangchain_core.utilsr   r   Úpydanticr   r   r   Úlangchain_community.llms.utilsr   r   r4   r*   r(   Ú<module>rZ      s.   ðß 5Õ 5ã Ý =Ý 3ß Lß ;Ñ ;å >ôk�#õ kr*   