§
    šŠtjÌ  ã                   óx   — d Z ddlmZmZmZ ddlZddlmZ ddlm	Z	m
Z
mZ ddlmZmZmZ  G d„ dee¦  «        ZdS )	z#This file is for LLMRails Embeddingé    )ÚDictÚListÚOptionalN)Ú
Embeddings)Úconvert_to_secret_strÚget_from_dict_or_envÚpre_init)Ú	BaseModelÚ
ConfigDictÚ	SecretStrc                   óÈ   — e Zd ZU dZdZeed<   	 dZee	         ed<   	  e
d¬¦  «        Z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 )ÚLLMRailsEmbeddingsa÷  LLMRails embedding models.

    To use, you should have the  environment
    variable ``LLM_RAILS_API_KEY`` set with your API key or pass it
    as a named parameter to the constructor.

    Model can be one of ["embedding-english-v1","embedding-multi-v1"]

    Example:
        .. code-block:: python

            from langchain_community.embeddings import LLMRailsEmbeddings
            cohere = LLMRailsEmbeddings(
                model="embedding-english-v1", api_key="my-api-key"
            )
    zembedding-english-v1ÚmodelNÚapi_keyÚforbid)ÚextraÚvaluesÚreturnc                 óL   — t          t          |dd¦  «        ¦  «        }||d<   |S )z,Validate that api key exists in environment.r   ÚLLM_RAILS_API_KEY)r   r   )Úclsr   r   s      úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/embeddings/llm_rails.pyÚvalidate_environmentz'LLMRailsEmbeddings.validate_environment'   s4   € õ (Ý  ¨Ð4GÑHÔHñ
ô 
ˆð $ˆˆyÑØˆó    Útextsc                 ó¼   — t          j        dd| j                             ¦   «         i|| j        dœd¬¦  «        }d„ |                     ¦   «         d         D ¦   «         S )z´Call out to Cohere's embedding endpoint.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        z&https://api.llmrails.com/v1/embeddingsz	X-API-KEY)Úinputr   é<   )ÚheadersÚjsonÚtimeoutc                 ó   — g | ]
}|d          ‘ŒS )Ú	embedding© )Ú.0Úitems     r   ú
<listcomp>z6LLMRailsEmbeddings.embed_documents.<locals>.<listcomp>?   s   € ÐFÐFÐF d��[Ô!ÐFÐFÐFr   Údata)ÚrequestsÚpostr   Úget_secret_valuer   r    )Úselfr   Úresponses      r   Úembed_documentsz"LLMRailsEmbeddings.embed_documents0   sg   € õ ”=Ø4Ø  $¤,×"?Ò"?Ñ"AÔ"AÐBØ ¨4¬:Ð6Ð6Øð	
ñ 
ô 
ˆð GÐF¨h¯mªm©o¬o¸fÔ.EÐFÑFÔFÐFr   Útextc                 ó:   — |                       |g¦  «        d         S )zœCall out to Cohere's embedding endpoint.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )r.   )r,   r/   s     r   Úembed_queryzLLMRailsEmbeddings.embed_queryA   s   € ð ×#Ò# T FÑ+Ô+¨AÔ.Ð.r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚstrÚ__annotations__r   r   r   r   Úmodel_configr	   r   r   r   Úfloatr.   r1   r$   r   r   r   r      sï   € € € € € € ðð ð" (€Eˆ3Ð'Ð'Ñ'Øà#'€GˆX�iÔ Ð'Ð'Ñ'Øà�:Øðñ ô €Lð ð¨$ð °4ð ð ð ñ „XððG T¨#¤Yð G°4¸¸U¼Ô3Dð Gð Gð Gð Gð"	/ ð 	/¨¨U¬ð 	/ð 	/ð 	/ð 	/ð 	/ð 	/r   r   )r5   Útypingr   r   r   r)   Úlangchain_core.embeddingsr   Úlangchain_core.utilsr   r   r	   Úpydanticr
   r   r   r   r$   r   r   ú<module>r>      s¶   ðØ )Ð )à 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'à €€€Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5ð?/ð ?/ð ?/ð ?/ð ?/˜ Jñ ?/ô ?/ð ?/ð ?/ð ?/r   