U
    hQ                     @   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root_validatorc                   @   s   e Zd ZU dZeed< dZeed< edd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modelT)pre)valuesreturnc              
   C   sL   zddl m} W n, tk
r< } ztd|W 5 d}~X Y nX | |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   F/tmp/pip-unpacked-wheel-9gdii04g/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_query6   s    	zAwaEmbeddings.embed_query)__name__
__module____qualname____doc__r   __annotations__r
   strr   r   r   r   r   floatr   r   r   r   r   r   r      s   

r   N)
typingr   r   r   Zlangchain_core.embeddingsr   Zlangchain_core.pydantic_v1r   r   r   r   r   r   r   <module>   s   