
    Ng	                     \    d dl mZmZmZmZ d dlmZ d dlmZm	Z	m
Z
  G d dee          ZdS )    )AnyDictListOptional)
Embeddings)	BaseModel
ConfigDictmodel_validatorc                   2   e Zd ZU dZdZee         ed<   dZee	         ed<   dZ
ee         ed<   i Zee         ed<   eed<    ed	
          Z ed          ededefd                        Zdee         deee                  fdZdedee         fdZdS )GPT4AllEmbeddingsa  GPT4All embedding models.

    To use, you should have the gpt4all python package installed

    Example:
        .. code-block:: python

            from langchain_community.embeddings import GPT4AllEmbeddings

            model_name = "all-MiniLM-L6-v2.gguf2.f16.gguf"
            gpt4all_kwargs = {'allow_download': 'True'}
            embeddings = GPT4AllEmbeddings(
                model_name=model_name,
                gpt4all_kwargs=gpt4all_kwargs
            )
    N
model_name	n_threadscpudevicegpt4all_kwargsclient )protected_namespacesbefore)modevaluesreturnc                 
   	 ddl m}  |d
|                    d          |                    d          |                    d          d|                    d          pi |d<   n# t          $ r t          d	          w xY w|S )z+Validate that GPT4All library is installed.r   )	Embed4Allr   r   r   )r   r   r   r   r   zuCould not import gpt4all library. Please install the gpt4all library to use this embedding model: pip install gpt4allr   )gpt4allr   getImportError)clsr   r   s      b/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/embeddings/gpt4all.pyvalidate_environmentz&GPT4AllEmbeddings.validate_environment!   s    	))))))(y  !::l33 **[11zz(++    ::.//52	   F8  	 	 	@  	 s   A#A& &B textsc                 8      fd|D             }d |D             S )zEmbed a list of documents using GPT4All.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        c                 D    g | ]}j                             |          S r   )r   embed).0textselfs     r   
<listcomp>z5GPT4AllEmbeddings.embed_documents.<locals>.<listcomp>@   s)    @@@$dk''--@@@    c                 R    g | ]$}t          t          t          |                    %S r   )listmapfloat)r%   es     r   r(   z5GPT4AllEmbeddings.embed_documents.<locals>.<listcomp>A   s(    888S]]##888r)   r   )r'   r!   
embeddingss   `  r   embed_documentsz!GPT4AllEmbeddings.embed_documents6   s3     A@@@%@@@
88Z8888r)   r&   c                 :    |                      |g          d         S )zEmbed a query using GPT4All.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )r0   )r'   r&   s     r   embed_queryzGPT4AllEmbeddings.embed_queryC   s     ##TF++A..r)   )__name__
__module____qualname____doc__r   r   str__annotations__r   intr   r   dictr   r	   model_configr
   classmethodr   r    r   r-   r0   r2   r   r)   r   r   r      s&         " !%J$$$#Ix}###!FHSM!!!%'NHTN'''KKK:2666L_(###$ 3    [ $#&9T#Y 94U3D 9 9 9 9	/ 	/U 	/ 	/ 	/ 	/ 	/ 	/r)   r   N)typingr   r   r   r   langchain_core.embeddingsr   pydanticr   r	   r
   r   r   r)   r   <module>r@      s    , , , , , , , , , , , , 0 0 0 0 0 0 ; ; ; ; ; ; ; ; ; ;E/ E/ E/ E/ E/	: E/ E/ E/ E/ E/r)   