
    NgV                     T    d dl mZmZmZ d dlmZ d dlmZmZ  G d dee          Z	dS )    )AnyDictList)
Embeddings)	BaseModelmodel_validatorc                       e Zd ZU dZeed<   dZeed<    ed          e	de
defd	                        Zd
eddfdZdee         deee                  fdZdedee         fdZdS )AwaEmbeddingszEmbedding documents and queries with Awa DB.

    Attributes:
        client: The AwaEmbedding client.
        model: The name of the model used for embedding.
         Default is "all-mpnet-base-v2".
    clientzall-mpnet-base-v2modelbefore)modevaluesreturnc                 t    	 ddl m} n"# t          $ r}t          d          |d}~ww xY w |            |d<   |S )z)Validate that awadb library is installed.r   )AwaEmbeddingzJCould not import awadb library. Please install it with `pip install awadb`Nr   )awadbr   ImportError)clsr   r   excs       ^/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/embeddings/awa.pyvalidate_environmentz"AwaEmbeddings.validate_environment   sn    
	******* 	 	 	=  	
 (<>>xs   	 
(#(
model_nameNc                 ,    || _         || j        _        dS )zSet the model used for embedding.
        The default model used is all-mpnet-base-v2

        Args:
            model_name: A string which represents the name of model.
        N)r   r   r   )selfr   s     r   	set_modelzAwaEmbeddings.set_model"   s      
!+    textsc                 6    | j                             |          S )zEmbed a list of documents using AwaEmbedding.

        Args:
            texts: The list of texts need to be embedded

        Returns:
            List of embeddings, one for each text.
        )r   EmbeddingBatch)r   r   s     r   embed_documentszAwaEmbeddings.embed_documents,   s     {))%000r   textc                 6    | j                             |          S )zCompute query embeddings using AwaEmbedding.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        )r   	Embedding)r   r"   s     r   embed_queryzAwaEmbeddings.embed_query7   s     {$$T***r   )__name__
__module____qualname____doc__r   __annotations__r   strr   classmethodr   r   r   r   floatr!   r%    r   r   r
   r
      s           KKK$E3$$$_(###$ 3    [ $#,C ,D , , , ,	1T#Y 	14U3D 	1 	1 	1 	1	+ 	+U 	+ 	+ 	+ 	+ 	+ 	+r   r
   N)
typingr   r   r   langchain_core.embeddingsr   pydanticr   r   r
   r.   r   r   <module>r2      s    " " " " " " " " " " 0 0 0 0 0 0 / / / / / / / /9+ 9+ 9+ 9+ 9+Iz 9+ 9+ 9+ 9+ 9+r   