Ë
    µŒjÎ,  ã                   óÆ   — d dl mZmZmZmZmZ d dlmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZ d dlmZ  G d„ de	«      Zed	k(  r e«       Z eej/                  d
«      «       yy)é    )ÚAnyÚDictÚListÚOptionalÚSequence)ÚCallbackManagerForLLMRun)ÚLLM)Úconvert_to_secret_strÚget_from_dict_or_envÚpre_init)Ú
ConfigDictÚ	SecretStr)Úenforce_stop_tokensc                   óÊ  — e Zd ZU dZdZeed<   dZe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<   	 dZeed<   	 dZee   ed<   	 dZee   ed<   	 dZee	   ed<   	 dZeee	      ed<   	 dZee   ed<   	 dZee   ed<   	 dZeed<   	 dZeeeef      ed<   	 dZee   ed<   	 dZee   ed<   	 dZee   ed<   d
Z e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"<   dZ&ee'e	      ed#<   dZ(eed$<   dZ)ee'e	      ed%<   dZ*eed&<   	 dZ+ee   ed'<   	 d(Z,ee   ed)<   	 d(Z-eed*<   	 dZ.eed+<   	 dZ/eee	      ed,<   	 dZ0ee1   ed-<   	 d.Z2e	ed/<   	 dZ3ee	   ed0<   	 d1Z4eed2<   	 d3Z5eed4<   	 dZ6eed5<   	  e7d6¬7«      Z8e9d8ed9efd:„«       Z:e;d9ee	ef   fd;„«       Z<e;d9ee	ef   fd<„«       Z=e;d9e	fd=„«       Z>	 	 dCd>e	d?eee	      d@ee?   dAed9e	f
dB„Z@y)DÚ
AlephAlphaam  Aleph Alpha large language models.

    To use, you should have the ``aleph_alpha_client`` python package installed, and the
    environment variable ``ALEPH_ALPHA_API_KEY`` set with your API key, or pass
    it as a named parameter to the constructor.

    Parameters are explained more in depth here:
    https://github.com/Aleph-Alpha/aleph-alpha-client/blob/c14b7dd2b4325c7da0d6a119f6e76385800e097b/aleph_alpha_client/completion.py#L10

    Example:
        .. code-block:: python

            from langchain_community.llms import AlephAlpha
            aleph_alpha = AlephAlpha(aleph_alpha_api_key="my-api-key")
    NÚclientzluminous-baseÚmodelé@   Úmaximum_tokensg        Útemperaturer   Útop_kÚtop_pÚpresence_penaltyÚfrequency_penaltyFÚ#repetition_penalties_include_promptÚ#use_multiplicative_presence_penaltyÚpenalty_biasÚpenalty_exceptionsÚ)penalty_exceptions_include_stop_sequencesÚbest_ofé   ÚnÚ
logit_biasÚ	log_probsÚtokensÚdisable_optimizationsÚminimum_tokensÚechoÚ$use_multiplicative_frequency_penaltyÚsequence_penaltyé   Úsequence_penalty_min_lengthÚ#use_multiplicative_sequence_penaltyÚcompletion_bias_inclusionÚ*completion_bias_inclusion_first_token_onlyÚcompletion_bias_exclusionÚ*completion_bias_exclusion_first_token_onlyÚcontextual_control_thresholdTÚcontrol_log_additiveÚ'repetition_penalties_include_completionÚraw_completionÚstop_sequencesÚaleph_alpha_api_keyzhttps://api.aleph-alpha.comÚhostÚhostingi1  Úrequest_timeout_secondsé   Útotal_retriesÚniceÚforbid)ÚextraÚvaluesÚreturnc           	      óØ   — t        t        |dd«      «      |d<   	 ddlm}  ||d   j	                  «       |d   |d   |d   |d   |d	   ¬
«      |d<   |S # t
        $ r t        d«      ‚w xY w)z?Validate that api key and python package exists in environment.r7   ÚALEPH_ALPHA_API_KEYr   )ÚClientr8   r9   r:   r<   r=   )Útokenr8   r9   r:   r<   r=   r   zlCould not import aleph_alpha_client python package. Please install it with `pip install aleph_alpha_client`.)r
   r   Úaleph_alpha_clientrD   Úget_secret_valueÚImportError)Úclsr@   rD   s      ún/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/aleph_alpha.pyÚvalidate_environmentzAlephAlpha.validate_environment©   s�   € ô )>Ü  Ð)>Ð@UÓVó)
ˆÐ$Ñ%ð	Ý1á%ØÐ2Ñ3×DÑDÓFØ˜F‘^Ø˜yÑ)Ø(.Ð/HÑ(IØ$ _Ñ5Ø˜F‘^ô ˆF�8Ñð ˆøô ò 	ÜðKóð ð	ús   ›7A ÁA)c                 óú  — i d| j                   “d| j                  “d| j                  “d| j                  “d| j                  “d| j
                  “d| j                  “d| j                  “d	| j                  “d
| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                   “| j"                  | j$                  | j&                  | j(                  | j*                  | j,                  | j.                  | j0                  | j2                  | j4                  | j6                  | j8                  | j:                  | j<                  dœ¥S )z;Get the default parameters for calling the Aleph Alpha API.r   r   r   r   r   r   r"   r   r   r   r   r   r    r#   r$   r%   r&   )r'   r(   r)   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   )r   r   r   r   r   r   r"   r   r   r   r   r   r    r#   r$   r%   r&   r'   r(   r)   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   ©Úselfs    rJ   Ú_default_paramszAlephAlpha._default_paramsÁ   s¯  € ð 
Ø˜d×1Ñ1ð 
à˜4×+Ñ+ð 
ð �T—Z‘Zð 
ð �T—Z‘Zð	 
ð
  × 5Ñ 5ð 
ð   ×!7Ñ!7ð 
ð �—‘ð 
ð 2°4×3[Ñ3[ð 
ð 2°4×3[Ñ3[ð 
ð ˜D×-Ñ-ð 
ð ! $×"9Ñ"9ð 
ð 8¸×9gÑ9gð 
ð �t—|‘|ð 
ð ˜$Ÿ/™/ð 
ð ˜Ÿ™ð 
ð  �d—k‘kð! 
ð" $ T×%?Ñ%?ð# 
ð$ #×1Ñ1Ø—I‘IØ48×4]Ñ4]Ø $× 5Ñ 5Ø+/×+KÑ+KØ37×3[Ñ3[Ø)-×)GÑ)GØ:>×:iÑ:iØ)-×)GÑ)GØ:>×:iÑ:iØ,0×,MÑ,MØ$(×$=Ñ$=Ø7;×7cÑ7cØ"×1Ñ1ò? 
ð  	
ó    c                 ó:   — i d| j                   i¥| j                  ¥S )zGet the identifying parameters.r   )r   rO   rM   s    rJ   Ú_identifying_paramszAlephAlpha._identifying_paramsæ   s$   € ð A�7˜DŸJ™JÐ'Ð@¨4×+?Ñ+?Ð@Ð@rP   c                  ó   — y)zReturn type of llm.Úaleph_alpha© rM   s    rJ   Ú	_llm_typezAlephAlpha._llm_typeë   s   € ð rP   ÚpromptÚstopÚrun_managerÚkwargsc                 óš  — ddl m}m} | j                  }| j                  �|�t        d«      ‚| j                  �| j                  |d<   n||d<   i |¥|¥} |dd|j                  |«      i|¤Ž}| j                  j                  | j                  |¬«      }	|	j                  d   j                  }
|€| j                  �t        |
|d   «      }
|
S )at  Call out to Aleph Alpha's completion 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 = aleph_alpha("Tell me a joke.")
        r   )ÚCompletionRequestÚPromptz:stop sequences found in both the input and default params.r6   rW   )r   ÚrequestrU   )rF   r\   r]   rO   r6   Ú
ValueErrorÚ	from_textr   Úcompleter   ÚcompletionsÚ
completionr   )rN   rW   rX   rY   rZ   r\   r]   Úparamsr^   ÚresponseÚtexts              rJ   Ú_callzAlephAlpha._callð   sç   € ÷* 	Aà×%Ñ%ˆØ×ÑÐ*¨tÐ/?ÜØLóð ð × Ñ Ð,Ø'+×':Ñ':ˆFÐ#Ò$à'+ˆFÐ#Ñ$Ø%�FÐ%˜fÐ%ˆÙ#ÑN¨6×+;Ñ+;¸FÓ+CÐNÀvÑNˆØ—;‘;×'Ñ'¨d¯j©jÀ'Ð'ÓJˆØ×#Ñ# AÑ&×1Ñ1ˆð Ð˜t×2Ñ2Ð>Ü& t¨VÐ4DÑ-EÓFˆDØˆrP   )NN)AÚ__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   Ústrr   Úintr   Úfloatr   r   r   r   r   Úboolr   r   r   r   r   r    r"   r#   r   r$   r%   r&   r'   r(   r)   r*   r,   r-   r.   r   r/   r0   r1   r2   r3   r4   r5   r6   r7   r   r8   r9   r:   r<   r=   r   Úmodel_configr   rK   ÚpropertyrO   rR   rV   r   rg   rU   rP   rJ   r   r      s‡  … ñð  €FˆCÓØ*€Eˆ8�C‰=Ó*Øà€N�CÓØ7à€K�ÓØQà€Eˆ3ƒNØ@à€Eˆ5ÓØDà!Ð�eÓ!Ø$à"Ð�uÓ"Ø;à:?Ð'¨°$©Ó?ð ð ;@Ð'¨°$©Ó?ð6ð #'€L�(˜3‘-Ó&Ø*à.2Ð˜  c¡Ñ+Ó2ð,ð AEÐ-¨x¸©~ÓDØBà!€GˆX�c‰]Ó!ðð €A€sƒJØ;à-1€J�˜˜c 5˜jÑ)Ñ*Ó1ØQà#€Iˆx˜‰}Ó#ØRà"€FˆH�T‰NÓ"Ø&à,1Ð˜8 D™>Ó1à$%€N�H˜S‘MÓ%Ø2à€Dˆ$ÓØ,à16Ð(¨$Ó6à!Ð�eÓ!à'(Ð Ó(à05Ð'¨Ó5à9=Ð˜x¨°©Ñ6Ó=à7<Ð.°Ó<à9=Ð˜x¨°©Ñ6Ó=à7<Ð.°Ó<ØJà48Ð  (¨5¡/Ó8ðð
 ,0Ð˜( 4™.Ó/ðð 59Ð+¨TÓ8ð(ð !€N�DÓ Ø?à*.€N�H˜T #™YÑ'Ó.Ø ð 04Ð˜ )Ñ,Ó3Ø&Ø-€Dˆ#Ó-ð9à!€GˆX�c‰]Ó!ð4ð $'Ð˜SÓ&ðWð €M�3Óðð €Dˆ$Óð>ñ Øô€Lð ð¨$ð °4ò ó ðð. ð"
  c¨3 h¡ò "
ó ð"
ðH ðA T¨#¨s¨(¡^ò Aó ðAð ð˜3ò ó ðð %)Ø:>ñ	(àð(ð �t˜C‘yÑ!ð(ð Ð6Ñ7ð	(ð
 ð(ð 
ô(rP   r   Ú__main__zHow are you?N)Útypingr   r   r   r   r   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úlangchain_core.utilsr
   r   r   Úpydanticr   r   Úlangchain_community.llms.utilsr   r   rh   ÚaaÚprintÚinvokerU   rP   rJ   Ú<module>r}      sS   ðß 6Õ 6å =Ý 3ß VÑ Vß *å >ôM�ô Mð` ˆzÒÙ	‹€Bá	ˆ"�)‰)�NÓ
#Õ$ð rP   