a
    bgV                     @   sF   d dl mZmZmZ d dlmZ d dlmZmZ G dd deeZ	dS )    )AnyDictList)
Embeddings)	BaseModelmodel_validatorc                   @   s   e Zd ZU dZeed< dZeed< edde	e
eddd	Zed
dddZee eee  dddZeee dd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              
   C   sN   zddl m} W n. ty> } ztd|W Y d}~n
d}~0 0 | |d< |S )z)Validate that awadb library is installed.r   )AwaEmbeddingzJCould not import awadb library. Please install it with `pip install awadb`Nr	   )Zawadbr   ImportError)clsr   r   exc r   p/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/embeddings/awa.pyvalidate_environment   s    
z"AwaEmbeddings.validate_environmentN)
model_namer   c                 C   s   || _ || 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   r   r   r   	set_model"   s    zAwaEmbeddings.set_model)textsr   c                 C   s   | 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	   ZEmbeddingBatch)r   r   r   r   r   embed_documents,   s    	zAwaEmbeddings.embed_documents)textr   c                 C   s   | j |S )zCompute query embeddings using AwaEmbedding.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        )r	   Z	Embedding)r   r   r   r   r   embed_query7   s    	zAwaEmbeddings.embed_query)__name__
__module____qualname____doc__r   __annotations__r
   strr   classmethodr   r   r   r   floatr   r   r   r   r   r   r      s   

r   N)
typingr   r   r   Zlangchain_core.embeddingsr   Zpydanticr   r   r   r   r   r   r   <module>   s   