§
    šŠtj  ã                   ód   — 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
mZmZ  G d„ de
e¦  «        ZdS )é    N)ÚAnyÚDictÚListÚOptional)Ú
Embeddings)Ú	BaseModelÚ
ConfigDictÚmodel_validatorc                   ó:  — e Zd ZU dZdZeed<   dZee	         ed<    e
dd¬¦  «        Z ed	¬
¦  «        edede	fd„¦   «         ¦   «         Zdee         deee                  fd„Zdedee         fd„Zdee         deee                  fd„Zdedee         fd„ZdS )ÚSpacyEmbeddingsa�  Embeddings by spaCy models.

    Attributes:
        model_name (str): Name of a spaCy model.
        nlp (Any): The spaCy model loaded into memory.

    Methods:
        embed_documents(texts: List[str]) -> List[List[float]]:
            Generates embeddings for a list of documents.
        embed_query(text: str) -> List[float]:
            Generates an embedding for a single piece of text.
    Úen_core_web_smÚ
model_nameNÚnlpÚforbid© )ÚextraÚprotected_namespacesÚbefore)ÚmodeÚvaluesÚreturnc                 óD  — |                      d¦  «        €d|d<   |                      d¦  «        }t          j                             d¦  «        €t	          d¦  «        ‚	 ddl}|                     |¦  «        |d<   n$# t          $ r t	          d|› d	|› d
�¦  «        ‚w xY w|S )aE  
        Validates that the spaCy package and the model are installed.

        Args:
            values (Dict): The values provided to the class constructor.

        Returns:
            The validated values.

        Raises:
            ValueError: If the spaCy package or the
            model are not installed.
        r   Nr   ÚspacyzDSpaCy package not found. Please install it with `pip install spacy`.r   r   zSpaCy model 'z>' not found. Please install it with `python -m spacy download z%`or provide a valid spaCy model name.)ÚgetÚ	importlibÚutilÚ	find_specÚ
ValueErrorr   ÚloadÚOSError)Úclsr   r   r   s       úm/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/embeddings/spacy_embeddings.pyÚvalidate_environmentz$SpacyEmbeddings.validate_environment   sÚ   € ð  �:Š:�lÑ#Ô#Ð+Ø#3ˆF�<Ñ à—Z’Z Ñ-Ô-ˆ
õ Œ>×#Ò# GÑ,Ô,Ð4ÝØVñô ð ð	àˆLˆLˆLà!ŸJšJ zÑ2Ô2ˆF�5‰MˆMøÝð 	ð 	ð 	åð7 
ð 7ð 7à.8ð7ð 7ð 7ñô ð ð	øøøð ˆs   ÁA< Á<!BÚtextsc                 ó    ‡ — ˆ fd„|D ¦   «         S )zâ
        Generates embeddings for a list of documents.

        Args:
            texts (List[str]): The documents to generate embeddings for.

        Returns:
            A list of embeddings, one for each document.
        c                 óh   •— g | ].}‰                      |¦  «        j                             ¦   «         ‘Œ/S r   ©r   ÚvectorÚtolist)Ú.0ÚtextÚselfs     €r"   ú
<listcomp>z3SpacyEmbeddings.embed_documents.<locals>.<listcomp>N   s2   ø€ ÐAÐAÐA°4�—’˜‘”Ô%×,Ò,Ñ.Ô.ÐAÐAÐAó    r   ©r,   r$   s   ` r"   Úembed_documentszSpacyEmbeddings.embed_documentsD   s    ø€ ð BÐAÐAÐA¸5ÐAÑAÔAÐAr.   r+   c                 óZ   — |                       |¦  «        j                             ¦   «         S )zÌ
        Generates an embedding for a single piece of text.

        Args:
            text (str): The text to generate an embedding for.

        Returns:
            The embedding for the text.
        r'   ©r,   r+   s     r"   Úembed_queryzSpacyEmbeddings.embed_queryP   s#   € ð �xŠx˜‰~Œ~Ô$×+Ò+Ñ-Ô-Ð-r.   c              ƒ   ó$   K  — t          d¦  «        ‚)aA  
        Asynchronously generates embeddings for a list of documents.
        This method is not implemented and raises a NotImplementedError.

        Args:
            texts (List[str]): The documents to generate embeddings for.

        Raises:
            NotImplementedError: This method is not implemented.
        ú3Asynchronous embedding generation is not supported.©ÚNotImplementedErrorr/   s     r"   Úaembed_documentsz SpacyEmbeddings.aembed_documents\   ó   è è € õ "Ð"WÑXÔXÐXr.   c              ƒ   ó$   K  — t          d¦  «        ‚)a<  
        Asynchronously generates an embedding for a single piece of text.
        This method is not implemented and raises a NotImplementedError.

        Args:
            text (str): The text to generate an embedding for.

        Raises:
            NotImplementedError: This method is not implemented.
        r5   r6   r2   s     r"   Úaembed_queryzSpacyEmbeddings.aembed_queryi   r9   r.   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚstrÚ__annotations__r   r   r   r	   Úmodel_configr
   Úclassmethodr   r#   r   Úfloatr0   r3   r8   r;   r   r.   r"   r   r      s]  € € € € € € ðð ð '€J�Ð&Ð&Ñ&Ø€Cˆ�#ŒÐÐÑà�: HÀ2ÐFÑFÔF€Là€_˜(Ð#Ñ#Ô#Øð%¨$ð %°3ð %ð %ð %ñ „[ñ $Ô#ð%ðN
B T¨#¤Yð 
B°4¸¸U¼Ô3Dð 
Bð 
Bð 
Bð 
Bð
. ð 
.¨¨U¬ð 
.ð 
.ð 
.ð 
.ðY¨D°¬Ið Y¸$¸tÀE¼{Ô:Kð Yð Yð Yð YðY sð Y¨t°E¬{ð Yð Yð Yð Yð Yð Yr.   r   )Úimportlib.utilr   Útypingr   r   r   r   Úlangchain_core.embeddingsr   Úpydanticr   r	   r
   r   r   r.   r"   ú<module>rI      s¯   ðØ Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ðlYð lYð lYð lYð lY�i ñ lYô lYð lYð lYð lYr.   