Ë
    µŒj‚  ã                   ó`   — d dl mZmZmZ d dlmZ d dlmZmZm	Z	m
Z
 d dlmZ  G d„ dee«      Zy)é    )ÚAnyÚListÚOptional)Ú
Embeddings)Ú	BaseModelÚ
ConfigDictÚFieldÚmodel_validator)ÚSelfc                   óD  — e Zd ZU dZdZeed<    ed¬«      Ze	ed<    edd¬	«      Z
eed<   	  ed
d¬	«      Zeed<   	  ed
d¬	«      Zeed<   	  edd¬	«      Zeed<   	  edd¬	«      Zeed<   	  edd¬	«      Zeed<   	  edd¬	«      Zeed<   	  edd¬	«      Zee   ed<   	  edd¬	«      Zee   ed<   	  edd¬	«      Zee   ed<   	  edd¬	«      Zeed<   	  edd¬	«      Zee	   ed<   	  edd¬«      Z ed¬«      defd„«       Zdee	   deee      fd „Z d!e	dee   fd"„Z!y)#ÚLlamaCppEmbeddingsaµ  llama.cpp embedding models.

    To use, you should have the llama-cpp-python library installed, and provide the
    path to the Llama model as a named parameter to the constructor.
    Check out: https://github.com/abetlen/llama-cpp-python

    Example:
        .. code-block:: python

            from langchain_community.embeddings import LlamaCppEmbeddings
            llama = LlamaCppEmbeddings(model_path="/path/to/model.bin")
    NÚclientÚ )ÚdefaultÚ
model_pathi   Ún_ctx)ÚaliaséÿÿÿÿÚn_partsÚseedFÚf16_kvÚ
logits_allÚ
vocab_onlyÚ	use_mlockÚ	n_threadsÚn_batchÚn_gpu_layersTÚverboseÚdeviceÚforbid© )ÚextraÚprotected_namespacesÚafter)ÚmodeÚreturnc                 óN  — | j                   }g d¢}|D �ci c]  }|t        | |«      “Œ }}| j                  �| j                  |d<   | j                  s	 ddlm}  ||fddi|¤Ž| _        | S | S c c}w # t        $ r t        d«      ‚t        $ r}t        d	|› d
|› �«      ‚d}~ww xY w)z4Validate that llama-cpp-python library is installed.)r   r   r   r   r   r   r   r   r   r   r   Nr   r   )ÚLlamaÚ	embeddingTz�Could not import llama-cpp-python library. Please install the llama-cpp-python library to use this embedding model: pip install llama-cpp-pythonz&Could not load Llama model from path: z. Received error )	r   Úgetattrr   r   Ú	llama_cppr(   ÚImportErrorÚ	ExceptionÚ
ValueError)Úselfr   Úmodel_param_namesÚkÚmodel_paramsr(   Úes          úq/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/embeddings/llamacpp.pyÚvalidate_environmentz'LlamaCppEmbeddings.validate_environmentE   sß   € ð —_‘_ˆ
ò
Ðñ 6GÓGÑ5F°˜œ7 4¨Ó+Ñ+Ð5FˆÐGà×ÑÐ(Ø+/×+<Ñ+<ˆL˜Ñ(à�{Š{ðÝ+á# JÑO¸$ÐOÀ,ÑO�”ð ˆˆtˆùò- Høô ò Ü!ðMóð ô
 ò Ü Ø<¸Z¸Lð I&Ø&' Sð*óð ûðús   •A-ÁA2 Á2B$ÂBÂB$Útextsc                 ó¾  — | j                   j                  |«      }g }|d   D ]w  }	 t        |d   d   t        «      r3|d   D ]*  }|j	                  t        t        t        |«      «      «       Œ, n+|j	                  t        t        t        |d   «      «      «       Œy |S # t        t        f$ r. |j	                  t        t        t        |d   «      «      «       Y Œ¸w xY w)z¼Embed a list of documents using the Llama model.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        Údatar)   r   )	r   Úcreate_embeddingÚ
isinstanceÚlistÚappendÚmapÚfloatÚ
IndexErrorÚ	TypeError)r/   r6   Ú
embeddingsÚfinal_embeddingsr3   r8   s         r4   Úembed_documentsz"LlamaCppEmbeddings.embed_documentsn   sÍ   € ð —[‘[×1Ñ1°%Ó8ˆ
ØÐØ˜FÔ#ˆAðJÜ˜a ™n¨QÑ/´Ô6Ø ! +¤˜Ø(×/Ñ/´´S¼ÀÓ5EÓ0FÕGñ !/ð %×+Ñ+¬D´´U¸A¸k¹NÓ1KÓ,LÔMøð $ð  Ðøô ¤	Ð*ò JØ ×'Ñ'¬¬S´¸¸+¹Ó-GÓ(HÖIðJús   §A4BÂ:CÃCÚtextc                 óì   — | j                   j                  |«      }|r?t        |t        «      r/t        |d   t        «      rt        t	        t
        |d   «      «      S t        t	        t
        |«      «      S )z˜Embed a query using the Llama model.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )r   Úembedr:   r;   r=   r>   )r/   rD   r)   s      r4   Úembed_queryzLlamaCppEmbeddings.embed_query„   sZ   € ð —K‘K×%Ñ% dÓ+ˆ	Ùœ I¬tÔ4¼ÀIÈaÁLÔRVÔ9WÜœœE 9¨Q¡<Ó0Ó1Ð1äœœE 9Ó-Ó.Ð.ó    )"Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r	   r   Ústrr   Úintr   r   r   Úboolr   r   r   r   r   r   r   r   r   r   Úmodel_configr
   r   r5   r   r>   rC   rG   r!   rH   r4   r   r      s–  … ñð €FˆCÓÙ BÔ'€J�Ó'á�s 'Ô*€Eˆ3Ó*Øá˜ 9Ô-€GˆSÓ-ð?ñ �b Ô'€Dˆ#Ó'Ø-á˜ hÔ/€FˆDÓ/Ø1á˜U¨,Ô7€J�Ó7Ø@á˜U¨,Ô7€J�Ó7Ø/á˜E¨Ô5€IˆtÓ5Ø,á$ T°Ô=€Iˆx˜‰}Ó=ð/ñ # 3¨iÔ8€GˆX�c‰]Ó8ð/ñ #(¨°NÔ"C€L�(˜3‘-ÓCØFá˜$ iÔ0€GˆTÓ0Ø)á! $¨hÔ7€FˆH�S‰MÓ7Ø2áØØô€Lñ
 ˜'Ô"ð& dò &ó #ð&ðP  T¨#¡Yð  °4¸¸U¹Ñ3Dó  ð,/ ð /¨¨U©ô /rH   r   N)Útypingr   r   r   Úlangchain_core.embeddingsr   Úpydanticr   r   r	   r
   Útyping_extensionsr   r   r!   rH   r4   Ú<module>rV      s'   ðß &Ñ &å 0ß BÓ BÝ "ôI/˜ Jõ I/rH   