
    7|h3                     6    d Z ddlmZ ddlmZ  G d de      Zy)z*Wrapper around model2vec embedding models.    )List)
Embeddingsc                   T    e Zd ZdZdefdZdee   deee      fdZdedee   fdZ	y	)
Model2vecEmbeddingsa`  Model2Vec embedding models.

    Install model2vec first, run 'pip install -U model2vec'.
    The github repository for model2vec is : https://github.com/MinishLab/model2vec

    Example:
        .. code-block:: python

            from langchain_community.embeddings import Model2vecEmbeddings

            embedding = Model2vecEmbeddings("minishlab/potion-base-8M")
            embedding.embed_documents([
                "It's dangerous to go alone!",
                "It's a secret to everybody.",
            ])
            embedding.embed_query(
                "Take this with you."
            )
    modelc                 x    	 ddl m} |j                  |      | _        y# t        $ r}t        d      |d}~ww xY w)zMInitialize embeddings.

        Args:
            model: Model name.
        r   )StaticModelzKUnable to import model2vec, please install with `pip install -U model2vec`.N)	model2vecr	   ImportErrorfrom_pretrained_model)selfr   r	   es       g/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/embeddings/model2vec.py__init__zModel2vecEmbeddings.__init__   sG    	- "11%8  	. 	s    	949textsreturnc                 T    | j                   j                  |      j                         S )zEmbed documents using the model2vec embeddings model.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        r   encodetolist)r   r   s     r   embed_documentsz#Model2vecEmbeddings.embed_documents,   s"     {{!!%(//11    textc                 T    | j                   j                  |      j                         S )zEmbed a query using the model2vec embeddings model.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )r   r   s     r   embed_queryzModel2vecEmbeddings.embed_query8   s"     {{!!$'..00r   N)
__name__
__module____qualname____doc__strr   r   floatr   r    r   r   r   r      sJ    (9c 9
2T#Y 
24U3D 
2
1 
1U 
1r   r   N)r    typingr   langchain_core.embeddingsr   r   r#   r   r   <module>r&      s    0  0:1* :1r   