Ë
    µŒ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mZ d dlmZ d dlmZ d	d
ddddœZ eddd¬«       G d„ de«      «       Zy)é    N)ÚAnyÚDictÚListÚMappingÚOptional)Ú
deprecated)ÚCallbackManagerForLLMRun)ÚLLM)Úget_from_dict_or_envÚpre_init)Ú
ConfigDict)Úenforce_stop_tokensÚtranslation_textÚsummary_textÚgenerated_text)ÚtranslationÚsummarizationÚconversationalztext-generationztext2text-generationz0.0.21z1.0z)langchain_huggingface.HuggingFaceEndpoint)Ú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<    ed¬	«      Zed
ede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)ÚHuggingFaceHuba  HuggingFaceHub  models.
    ! This class is deprecated, you should use HuggingFaceEndpoint instead.

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

    Supports `text-generation`, `text2text-generation`, `conversational`, `translation`,
     and `summarization`.

    Example:
        .. code-block:: python

            from langchain_community.llms import HuggingFaceHub
            hf = HuggingFaceHub(repo_id="gpt2", huggingfacehub_api_token="my-api-key")
    NÚclientÚrepo_idÚtaskÚmodel_kwargsÚhuggingfacehub_api_tokenÚforbid)ÚextraÚvaluesÚreturnc                 ób  — t        |dd«      }	 ddlm}m} |d   } |||¬«      }|d   s5|st	        d«      ‚ ||¬	«      j                  |¬
«      }|j                  |d<   |d   t        vr't	        d|d   › dt        j                  «       › d�«      ‚||d<   |S # t        $ r t        d«      ‚w xY w)z?Validate that api key and python package exists in environment.r   ÚHUGGINGFACEHUB_API_TOKENr   )ÚHfApiÚInferenceClientr   )ÚmodelÚtokenr   z1Must specify either `repo_id` or `task`, or both.)r'   )r   zGot invalid task z, currently only z are supportedr   zfCould not import huggingface_hub python package. Please install it with `pip install huggingface_hub`.)
r   Úhuggingface_hubr$   r%   Ú
ValueErrorÚ
model_infoÚpipeline_tagÚVALID_TASKS_DICTÚkeysÚImportError)Úclsr    r   r$   r%   r   r   r*   s           úr/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/huggingface_hub.pyÚvalidate_environmentz#HuggingFaceHub.validate_environment?   s  € ô $8ØÐ.Ð0Jó$
Ð ð	ß>à˜YÑ'ˆGÙ$ØØ.ôˆFð ˜&’>ÙÜ$ØKóð ñ #Ð)AÔB×MÑMØ#ð Nó �
ð ",×!8Ñ!8��v‘Ø�f‰~Ô%5Ñ5Ü Ø'¨¨v©Ð'7ð 8&Ü&6×&;Ñ&;Ó&=Ð%>¸nðNóð ð  &ˆF�8Ñð ˆøô ò 	ÜðHóð ð	ús   �BB ÂB.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     r0   Ú_identifying_paramsz"HuggingFaceHub._identifying_paramsd   s@   € ð ×)Ñ)Ò/¨Rˆð
ØŸ,™,°·	±	Ñ:ð
à˜}Ð-ð
ð 	
ó    c                  ó   — y)zReturn type of llm.r(   © )r3   s    r0   Ú	_llm_typezHuggingFaceHub._llm_typem   s   € ð !r6   ÚpromptÚstopÚrun_managerÚkwargsc                 ót  — | j                   xs i }i |¥|¥}| j                  j                  ||dœ| j                  ¬«      }t	        j
                  |j                  «       «      }d|v rt        d|d   › �«      ‚t        | j                     }t        |t        «      r	|d   |   }	n||   }	|�t        |	|«      }	|	S )an  Call out to HuggingFace Hub's inference 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 = hf("Tell me a joke.")
        )ÚinputsÚ
parameters)Újsonr   ÚerrorzError raised by inference API: r   )r   r   Úpostr   rA   ÚloadsÚdecoder)   r,   Ú
isinstanceÚlistr   )
r3   r:   r;   r<   r=   r4   r@   ÚresponseÚresponse_keyÚtexts
             r0   Ú_callzHuggingFaceHub._callr   sË   € ð* ×)Ñ)Ò/¨RˆØ0˜Ð0¨Ð0ˆ
à—;‘;×#Ñ#Ø"°*Ñ=ÀDÇIÁIð $ó 
ˆô —:‘:˜hŸo™oÓ/Ó0ˆØ�hÑÜÐ>¸xÈÑ?PÐ>QÐRÓSÐSä'¨¯	©	Ñ2ˆÜ�h¤Ô%Ø˜A‘;˜|Ñ,‰Dà˜LÑ)ˆDàÐô ' t¨TÓ2ˆDØˆr6   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   Ústrr   r   Údictr   r   Úmodel_configr   r   r1   Úpropertyr   r5   r9   r   r	   rK   r8   r6   r0   r   r      s  … ñð" €FˆCÓØ!€GˆX�c‰]Ó!ðLà€Dˆ(�3‰-Óðð $(€L�(˜4‘.Ó'Ø1à.2Ð˜h s™mÓ2áØô€Lð ð"¨$ð "°4ò "ó ð"ðH ð
 W¨S°#¨XÑ%6ò 
ó ð
ð ð!˜3ò !ó ð!ð %)Ø:>ñ	)àð)ð �t˜C‘yÑ!ð)ð Ð6Ñ7ð	)ð
 ð)ð 
ô)r6   r   )rA   Útypingr   r   r   r   r   Úlangchain_core._api.deprecationr   Úlangchain_core.callbacksr	   Ú#langchain_core.language_models.llmsr
   Úlangchain_core.utilsr   r   Úpydanticr   Úlangchain_community.llms.utilsr   r,   r   r8   r6   r0   Ú<module>r\      se   ðÛ ß 5Õ 5å 6Ý =Ý 3ß ?Ý å >ð
 &Ø#Ø&Ø'Ø,ñÐ ñ ØØØBôô
�Só óñ
r6   