§
    šŠtj’  ã                   ó¸   — 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dS )é    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                   óè  — 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dS )Ú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                 ó‚  — t          |dd¦  «        }	 ddlm}m} |                     d¦  «        r|d         |d<   n5|                     d¦  «        r|d         |d<   nt
          |d<   t
          |d<    ||d         |¬¦  «        } ||d         |¬¦  «        }||d<   ||d	<   n# t          $ r t          d
¦  «        ‚w xY w|S )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          úl/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/embeddings/huggingface_hub.pyÚvalidate_environmentz-HuggingFaceHubEmbeddings.validate_environment5   s,  € õ $8ØÐ.Ð0Jñ$
ô $
Ð ð	ØMÐMÐMÐMÐMÐMÐMÐMà�zŠz˜'Ñ"Ô"ð 2Ø$*¨7¤O��yÑ!Ð!Ø—’˜IÑ&Ô&ð 2Ø"(¨Ô"3��w‘�å"/��w‘Ý$1��yÑ!à$�_Ø˜W”oØ.ðñ ô ˆFð
 0Ð/Ø˜W”oØ.ðñ ô ˆLð
  &ˆF�8ÑØ%1ˆF�>Ñ"Ð"øåð 	ð 	ð 	ÝðHñô ð ð	øøøð
 ˆs   “BB" Â"B<Úafterc                 ób   — | 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\   sO   € ð Œ9�KÐ'Ð'Ýð> D¤Ið >ð >Ý"-ð>ð >ð >ñô ð ð ˆó    Útextsc                 óÂ   — d„ |D ¦   «         }| j         pi }| j                             d|i|¥| j        ¬¦  «        }t	          j        |                     ¦   «         ¦  «        S )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.
        c                 ó:   — g | ]}|                      d d¦  «        ‘ŒS ©ú
ú ©Úreplace©Ú.0Útexts     r-   ú
<listcomp>z<HuggingFaceHubEmbeddings.embed_documents.<locals>.<listcomp>p   ó&   € Ð;Ð;Ð;¨T�—’˜d CÑ(Ô(Ð;Ð;Ð;r5   Úinputs©Újsonr   )r   r   Úpostr   rE   ÚloadsÚdecode©r3   r6   Ú_model_kwargsÚ	responsess       r-   Úembed_documentsz(HuggingFaceHubEmbeddings.embed_documentsf   so   € ð <Ð;°UÐ;Ñ;Ô;ˆØÔ)Ð/¨Rˆà”K×$Ò$Ø˜EÐ3 ]Ð3¸$¼)ð %ñ 
ô 
ˆ	õ Œz˜)×*Ò*Ñ,Ô,Ñ-Ô-Ð-r5   c              ƒ   óÐ   K  — d„ |D ¦   «         }| j         pi }| j                             ||dœ| j        ¬¦  «        ƒ d{V —†}t	          j        |                     ¦   «         ¦  «        S )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.
        c                 ó:   — g | ]}|                      d d¦  «        ‘ŒS r9   r<   r>   s     r-   rA   z=HuggingFaceHubEmbeddings.aembed_documents.<locals>.<listcomp>‚   rB   r5   )rC   Ú
parametersrD   N)r   r   rF   r   rE   rG   rH   rI   s       r-   Úaembed_documentsz)HuggingFaceHubEmbeddings.aembed_documentsx   s�   è è € ð <Ð;°UÐ;Ñ;Ô;ˆØÔ)Ð/¨RˆØÔ+×0Ò0Ø!°Ð?Ð?ÀdÄið 1ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ˆ	õ Œz˜)×*Ò*Ñ,Ô,Ñ-Ô-Ð-r5   r@   c                 ó>   — |                       |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   )rL   ©r3   r@   Úresponses      r-   Úembed_queryz$HuggingFaceHubEmbeddings.embed_query‰   s#   € ð ×'Ò'¨¨Ñ/Ô/°Ô2ˆØˆr5   c              ƒ   óN   K  — |                       |g¦  «        ƒ d{V —†d         }|S )z¿Async Call to HuggingFaceHub's embedding endpoint for embedding query text.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        Nr   )rP   rR   s      r-   Úaembed_queryz%HuggingFaceHubEmbeddings.aembed_query•   s9   è è € ð ×/Ò/°°Ñ7Ô7Ð7Ð7Ð7Ð7Ð7Ð7¸Ô;ˆØˆr5   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   r   Ústrr   r   r   Údictr   r   Úmodel_configr   Úclassmethodr   r.   r   r4   r   ÚfloatrL   rP   rT   rV   r   r5   r-   r   r      së  € € € € € € ðð ð$ €FˆCÐÐÑØ€L�#ÐÐÑØ€Eˆ8�CŒ=ÐÐÑØØ!€GˆX�cŒ]Ð!Ð!Ñ!ØCØ.€Dˆ(�3Œ-Ð.Ð.Ñ.Ø&Ø#'€L�(˜4”.Ð'Ð'Ñ'Ø1à.2Ð˜h sœmÐ2Ð2Ñ2à�: HÀ2ÐFÑFÔF€Là€_˜(Ð#Ñ#Ô#Øð#¨$ð #°3ð #ð #ð #ñ „[ñ $Ô#ð#ðJ €_˜'Ð"Ñ"Ô"ð˜4ð ð ð ñ #Ô"ðð. T¨#¤Yð .°4¸¸U¼Ô3Dð .ð .ð .ð .ð$.¨D°¬Ið .¸$¸tÀE¼{Ô:Kð .ð .ð .ð .ð"
 ð 
¨¨U¬ð 
ð 
ð 
ð 
ð
 sð 
¨t°E¬{ð 
ð 
ð 
ð 
ð 
ð 
r5   r   )rE   Ú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>rg      s  ðØ €€€Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à *Ð *Ð *Ð *Ð *Ð *Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø "Ð "Ð "Ð "Ð "Ð "à9€Ø%€ð €Ø
ØØLðñ ô ð
Lð Lð Lð Lð L˜y¨*ñ Lô Lñô ð
Lð Lð Lr5   