o
    ZhV                     @   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	de
defd	d
ZdeddfddZdee deee  fddZdedee f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   sB   zddl m} W n ty } ztd|d}~ww | |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   Y/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/embeddings/awa.pyvalidate_environment   s   
z"AwaEmbeddings.validate_environment
model_nameNc                 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textsc                 C      | 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,      	zAwaEmbeddings.embed_documentstextc                 C   r   )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   r   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    