Ë
    µŒj)  ã                   óÎ   — d dl Z 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 d dlmZ d dlmZmZmZ d dlmZ  e j*                  e«      Z ed	d
d¬«       G d„ de«      «       Zy)é    N)ÚAnyÚDictÚListÚOptionalÚUnion)Ú
deprecated)ÚCallbackManagerForLLMRun)ÚLLM)Úget_from_dict_or_env)Ú	BaseModelÚ
ConfigDictÚmodel_validator)Úenforce_stop_tokensz0.3.28z1.0z)langchain_predictionguard.PredictionGuard)ÚsinceÚremovalÚalternative_importc                   óÆ  — e Zd ZU dZ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d<   	 dZee   ed<   	 dZeee	      ed<   dZeee	ee	ef   f      ed<   	 dZeee	ef      ed<   	 dZee	   ed<   	  ed¬«      Z ed¬«      dedefd„«       Zedee	ef   fd„«       Zede	fd„«       Zdedee	ef   fd„Z	 	 dde	deee	      dee    dede	f
d„Z!y) ÚPredictionGuardaÞ  Prediction Guard large language models.

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

    Example:
        .. code-block:: python

            llm = PredictionGuard(
                model="Hermes-3-Llama-3.1-8B",
                predictionguard_api_key="your Prediction Guard API key",
            )
    NÚclientzHermes-3-Llama-3.1-8BÚmodelé   Ú
max_tokensg      è?Útemperaturegš™™™™™¹?Útop_pÚtop_kÚstopÚpredictionguard_inputÚpredictionguard_outputÚpredictionguard_api_keyÚforbid)ÚextraÚbefore)ÚmodeÚvaluesÚreturnc                 óv   — t        |dd«      }	 ddlm}  ||¬«      |d<   |S # t        $ r t        d«      ‚w xY w)zCValidate that the api_key and python package exists in environment.r   ÚPREDICTIONGUARD_API_KEYr   )r   )Úapi_keyr   zfCould not import predictionguard python package. Please install it with `pip install predictionguard`.)r   Úpredictionguardr   ÚImportError)Úclsr$   Ú
pg_api_keyr   s       úr/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/predictionguard.pyÚvalidate_environmentz$PredictionGuard.validate_environmentB   s\   € ô *ØÐ-Ð/Hó
ˆ
ð	Ý7á.Ø"ô ˆF�8Ñð ˆøô ò 	ÜðHóð ð	ús   �# £8c                 ó   — d| j                   iS )zGet the identifying parameters.r   )r   ©Úselfs    r-   Ú_identifying_paramsz#PredictionGuard._identifying_paramsX   s   € ð ˜Ÿ™Ð$Ð$ó    c                  ó   — y)zReturn type of llm.r)   © r0   s    r-   Ú	_llm_typezPredictionGuard._llm_type]   s   € ð !r3   Úkwargsc           
      ó`  — |j                  d| j                  «      }|j                  d| j                  «      }i | j                  | j                  | j
                  | j                  t        |t        «      r|j                  «       n|t        |t        «      r|j                  «       n|dœ¥|¥}|S )Nr   r   )r   r   r   r   ÚinputÚoutput)
Úpopr   r   r   r   r   r   Ú
isinstancer   Ú
model_dump)r1   r7   r9   r:   Úparamss        r-   Ú_get_parameterszPredictionGuard._get_parametersb   s    € à—
‘
Ð2°D×4NÑ4NÓOˆØ—‘Ð4°d×6QÑ6QÓRˆð
à"Ÿo™oØ#×/Ñ/ØŸ™ØŸ™ä*4°U¼IÔ*F�E×$Ñ$Ô&ÈEô ,6°f¼iÔ+H�F×%Ñ%Ô'Èfñð
ð ð
ˆð  ˆr3   ÚpromptÚrun_managerc                 óÈ  —  | j                   di |¤Ž}d}| j                  �|�t        d«      ‚| j                  �| j                  }n|} | j                  j                  j
                  d| j                  |dœ|¤Ž}|d   D ]E  }|j                  dd«      j                  d«      sŒ%|d   j                  d«      }	t        d|	› �«      ‚ |d   d	   d
   }
|rt        |
|«      }
|
S )a$  Call out to Prediction Guard's model API.
        Args:
            prompt: The prompt to pass into the model.
        Returns:
            The string generated by the model.
        Example:
            .. code-block:: python
                response = llm.invoke("Tell me a joke.")
        Nz2`stop` found in both the input and default params.)r   r@   ÚchoicesÚstatusÚ zerror: z Error from PredictionGuard API: r   Útextr5   )r?   r   Ú
ValueErrorr   ÚcompletionsÚcreater   ÚgetÚ
startswithÚremoveprefixr   )r1   r@   r   rA   r7   r>   ÚstopsÚresponseÚresÚerr_msgrF   s              r-   Ú_callzPredictionGuard._cally   s  € ð" &�×%Ñ%Ñ/¨Ñ/ˆàˆØ�9‰9Ð  TÐ%5ÜÐQÓRÐRØ�Y‰YÐ"Ø—I‘I‰EàˆEà1�4—;‘;×*Ñ*×1Ñ1ð 
Ø—*‘*Øñ
ð ñ
ˆð ˜IÔ&ˆCØ�w‰w�x Ó$×/Ñ/°	Õ:Ø˜h™-×4Ñ4°YÓ?�Ü Ð#CÀGÀ9Ð!MÓNÐNð 'ð
 ˜	Ñ" 1Ñ% fÑ-ˆñ Ü& t¨UÓ3ˆDàˆr3   )NN)"Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   Ústrr   Úintr   Úfloatr   r   r   r   r   r   r   Úboolr   r   r   Úmodel_configr   r.   Úpropertyr2   r6   r?   r	   rQ   r5   r3   r-   r   r      s¢  … ñð €FˆCÓà2€Eˆ8�C‰=Ó2Øà #€J�˜‘Ó#ØAà#'€K�˜%‘Ó'ØQà €Eˆ8�E‰?Ó ØSà€Eˆ8�C‰=ÓØFà $€Dˆ(�4˜‘9Ñ
Ó$àCGÐ˜8 D¨¨e°C¸°IÑ.>Ð)>Ñ$?Ñ@ÓGØKà8<Ð˜H T¨#¨t¨)¡_Ñ5Ó<Ø9à-1Ð˜X c™]Ó1Ø#á HÔ-€Lá˜(Ô#ð¨$ð °4ò ó $ðð* ð% T¨#¨s¨(¡^ò %ó ð%ð ð!˜3ò !ó ð!ð¨ð °°S¸#°X±ó ð4 %)Ø:>ñ	-àð-ð �t˜C‘yÑ!ð-ð Ð6Ñ7ð	-ð
 ð-ð 
ô-r3   r   )ÚloggingÚtypingr   r   r   r   r   Úlangchain_core._api.deprecationr   Úlangchain_core.callbacksr	   Ú#langchain_core.language_models.llmsr
   Úlangchain_core.utilsr   Úpydanticr   r   r   Úlangchain_community.llms.utilsr   Ú	getLoggerrR   Úloggerr   r5   r3   r-   Ú<module>rg      sa   ðÛ ß 3Õ 3å 6Ý =Ý 3Ý 5ß ;Ñ ;å >à	ˆ×	Ñ	˜8Ó	$€ñ Ø
ØØBôô
R�có Róñ
Rr3   