Ë
    µŒj¸  ã                   ó¤   — d dl Z d dl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mZ d dlmZ dZd	Z ed
dd¬«       G d„ dee	«      «       Zy)é    N)ÚAnyÚDictÚListÚOptional)Ú
deprecated)Ú
Embeddings)Úget_from_dict_or_env)Ú	BaseModelÚ
ConfigDictÚmodel_validator)ÚSelfz'sentence-transformers/all-mpnet-base-v2)úfeature-extractionz0.2.2z1.0z3langchain_huggingface.HuggingFaceEndpointEmbeddings)ÚsinceÚremovalÚalternative_importc                   ót  — e Zd ZU dZ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d	<   	 dZe	e
   ed
<    edd¬«      Z ed¬«      ededefd„«       «       Z ed¬«      defd„«       Zdee
   deee      fd„Zdee
   deee      fd„Zde
dee   fd„Zde
dee   fd„Zy)ÚHuggingFaceHubEmbeddingsaw  HuggingFaceHub embedding models.

    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.

    Example:
        .. code-block:: python

            from langchain_community.embeddings import HuggingFaceHubEmbeddings
            model = "sentence-transformers/all-mpnet-base-v2"
            hf = HuggingFaceHubEmbeddings(
                model=model,
                task="feature-extraction",
                huggingfacehub_api_token="my-api-key",
            )
    NÚclientÚasync_clientÚmodelÚrepo_idr   ÚtaskÚmodel_kwargsÚhuggingfacehub_api_tokenÚforbid© )ÚextraÚprotected_namespacesÚbefore)ÚmodeÚvaluesÚreturnc                 ó6  — t        |dd«      }	 ddlm}m} |j	                  d«      r	|d   |d<   n,|j	                  d«      r	|d   |d<   nt
        |d<   t
        |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.r   ÚHUGGINGFACEHUB_API_TOKENr   )ÚAsyncInferenceClientÚInferenceClientr   r   )r   Útokenr   r   zfCould not import huggingface_hub python package. Please install it with `pip install huggingface_hub`.)r	   Úhuggingface_hubr%   r&   ÚgetÚDEFAULT_MODELÚImportError)Úclsr!   r   r%   r&   r   r   s          úx/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/embeddings/huggingface_hub.pyÚvalidate_environmentz-HuggingFaceHubEmbeddings.validate_environment5   sÒ   € ô $8ØÐ.Ð0Jó$
Ð ð	ßMà�z‰z˜'Ô"Ø$*¨7¡O��yÒ!Ø—‘˜IÔ&Ø"(¨Ñ"3��w’ä"/��w‘Ü$1��yÑ!á$Ø˜W‘oØ.ôˆFñ
 0Ø˜W‘oØ.ôˆLð
  &ˆF�8ÑØ%1ˆF�>Ñ"ð ˆøô ò 	ÜðHóð ð	ús   �A2B ÂBÚafterc                 ój   — | j                   t        vr t        d| j                   › dt        › d�«      ‚| S )z#Post init validation for the class.zGot invalid task z, currently only z are supported)r   ÚVALID_TASKSÚ
ValueError)Úselfs    r-   Ú	post_initz"HuggingFaceHubEmbeddings.post_init\   s@   € ð �9‰9œKÑ'ÜØ# D§I¡I ;ð /"Ü"- ¨nð>óð ð ˆó    Útextsc                 ó  — |D �cg c]  }|j                  dd«      ‘Œ }}| j                  xs i }| j                  j                  d|i|¥| j                  ¬«      }t        j                  |j                  «       «      S c c}w )zÖCall out to HuggingFaceHub's embedding endpoint for embedding search docs.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        Ú
Ú Úinputs©Újsonr   )Úreplacer   r   Úpostr   r<   ÚloadsÚdecode©r3   r6   ÚtextÚ_model_kwargsÚ	responsess        r-   Úembed_documentsz(HuggingFaceHubEmbeddings.embed_documentsf   s~   € ñ 6;Ó;±U¨T�—‘˜d CÕ(°UˆÐ;Ø×)Ñ)Ò/¨Rˆà—K‘K×$Ñ$Ø˜EÐ3 ]Ð3¸$¿)¹)ð %ó 
ˆ	ô �z‰z˜)×*Ñ*Ó,Ó-Ð-ùò <s   …A>c              ƒ   ó   K  — |D �cg c]  }|j                  dd«      ‘Œ }}| j                  xs i }| j                  j                  ||dœ| j                  ¬«      ƒ d{  –—† }t        j                  |j                  «       «      S c c}w 7 Œ,­w)zØAsync Call to HuggingFaceHub's embedding endpoint for embedding search docs.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        r8   r9   )r:   Ú
parametersr;   N)r=   r   r   r>   r   r<   r?   r@   rA   s        r-   Úaembed_documentsz)HuggingFaceHubEmbeddings.aembed_documentsx   s‰   è ø€ ñ 6;Ó;±U¨T�—‘˜d CÕ(°UˆÐ;Ø×)Ñ)Ò/¨RˆØ×+Ñ+×0Ñ0Ø!°Ñ?ÀdÇiÁið 1ó 
÷ 
ˆ	ô �z‰z˜)×*Ñ*Ó,Ó-Ð-ùò <ð
ús   ‚B‡B ?BÁBÁ -BrB   c                 ó0   — | j                  |g«      d   }|S )z½Call out to HuggingFaceHub's embedding endpoint for embedding query text.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )rE   ©r3   rB   Úresponses      r-   Úembed_queryz$HuggingFaceHubEmbeddings.embed_query‰   s    € ð ×'Ñ'¨¨Ó/°Ñ2ˆØˆr5   c              ƒ   óL   K  — | j                  |g«      ƒ d{  –—† d   }|S 7 Œ	­w)z¿Async Call to HuggingFaceHub's embedding endpoint for embedding query text.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        Nr   )rH   rJ   s      r-   Úaembed_queryz%HuggingFaceHubEmbeddings.aembed_query•   s,   è ø€ ð ×/Ñ/°°Ó7×7¸Ñ;ˆØˆð 8ús   ‚$˜"™
$)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r   Ústrr   r   r   Údictr   r   Úmodel_configr   Úclassmethodr   r.   r   r4   r   ÚfloatrE   rH   rL   rN   r   r5   r-   r   r      s8  … ñð$ €FˆCÓØ€L�#ÓØ€Eˆ8�C‰=ÓØØ!€GˆX�c‰]Ó!ØCØ.€Dˆ(�3‰-Ó.Ø&Ø#'€L�(˜4‘.Ó'Ø1à.2Ð˜h s™mÓ2á HÀ2ÔF€Lá˜(Ô#Øð#¨$ð #°3ò #ó ó $ð#ñJ ˜'Ô"ð˜4ò ó #ðð. T¨#¡Yð .°4¸¸U¹Ñ3Dó .ð$.¨D°©Ið .¸$¸tÀE¹{Ñ:Kó .ð"
 ð 
¨¨U©ó 
ð
 sð 
¨t°E©{ô 
r5   r   )r<   Útypingr   r   r   r   Úlangchain_core._apir   Úlangchain_core.embeddingsr   Úlangchain_core.utilsr	   Úpydanticr
   r   r   Útyping_extensionsr   r*   r1   r   r   r5   r-   Ú<module>r_      sX   ðÛ ß ,Ó ,å *Ý 0Ý 5ß ;Ñ ;Ý "à9€Ø%€ñ Ø
ØØLôô
L˜y¨*ó Lóñ
Lr5   