
    Ng                        d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZ ddZ G d de
e          Z G d de          ZdS )    )annotations)AnyDictIteratorList)urlparse)
Embeddings)	BaseModelPrivateAttrtexts	List[str]sizeintreturnIterator[List[str]]c              #  j   K   t          dt          |           |          D ]}| |||z            V  d S )Nr   )rangelen)r   r   is      a/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/embeddings/mlflow.py_chunkr   
   sM      1c%jj$'' " "ADL!!!!!" "    c                       e Zd ZU dZded<   	 ded<   	  e            Zded<   	 i Zded<   	 i Zded	<   d fdZ	e
dd            ZddZddZddZddZ xZS )MlflowEmbeddingsa  Embedding LLMs in MLflow.

    To use, you should have the `mlflow[genai]` python package installed.
    For more information, see https://mlflow.org/docs/latest/llms/deployments.

    Example:
        .. code-block:: python

            from langchain_community.embeddings import MlflowEmbeddings

            embeddings = MlflowEmbeddings(
                target_uri="http://localhost:5000",
                endpoint="embeddings",
            )
    strendpoint
target_urir   _clientDict[str, str]query_paramsdocuments_paramskwargsc                     t                      j        di | |                                  	 ddlm}  || j                  | _        d S # t          $ r}t          d| j         d          |d }~ww xY w)Nr   )get_deploy_clientz;Failed to create the client. Please run `pip install mlflowz#` to install required dependencies. )	super__init___validate_urimlflow.deploymentsr$   r   r   ImportError_mlflow_extras)selfr"   r$   e	__class__s       r   r'   zMlflowEmbeddings.__init__*   s    ""6"""		<<<<<<,,T_==DLLL 	 	 	)151D) ) )  		s   A 
A5A00A5r   c                    dS )Nz[genai]r%   )r,   s    r   r+   zMlflowEmbeddings._mlflow_extras8   s    yr   Nonec                    | j         dk    rd S g d}t          | j                   j        |vrt          d| j          d| d          d S )N
databricks)httphttpsr2   zInvalid target URI: z. The scheme must be one of .)r   r   scheme
ValueError)r,   alloweds     r   r(   zMlflowEmbeddings._validate_uri<   sv    ?l**F111DO$$+7::8t 8 8-48 8 8   ;:r   r   r   paramsList[List[float]]c                    g }t          |d          D ]L}| j                            | j        d|i|          }|                    d |d         D                        M|S )N   input)r   inputsc              3  &   K   | ]}|d          V  dS )	embeddingNr%   ).0rs     r   	<genexpr>z)MlflowEmbeddings.embed.<locals>.<genexpr>M   s&      CCanCCCCCCr   data)r   r   predictr   extend)r,   r   r9   
embeddingstxtresps         r   embedzMlflowEmbeddings.embedF   s    (*
%$$ 	D 	DC<''// (  D CCd6lCCCCCCCr   c                :    |                      || j                  S )Nr9   )rJ   r!   )r,   r   s     r   embed_documentsz MlflowEmbeddings.embed_documentsP   s    zz%(=z>>>r   textList[float]c                H    |                      |g| j                  d         S )NrL   r   )rJ   r    )r,   rN   s     r   embed_queryzMlflowEmbeddings.embed_queryS   s"    zz4&):z;;A>>r   )r"   r   )r   r   )r   r0   )r   r   r9   r   r   r:   )r   r   r   r:   )rN   r   r   rO   )__name__
__module____qualname____doc____annotations__r   r   r    r!   r'   propertyr+   r(   rJ   rM   rQ   __classcell__)r.   s   @r   r   r      s           MMMOOO ;==G    ,#%L%%%%.')))))         X      ? ? ? ?? ? ? ? ? ? ? ?r   r   c                  8    e Zd ZU dZddiZded<   ddiZded<   dS )	MlflowCohereEmbeddingsz Cohere embedding LLMs in MLflow.
input_typesearch_queryr   r    search_documentr!   N)rR   rS   rT   rU   r    rV   r!   r%   r   r   rZ   rZ   W   sF         **$0.#ALAAAA(46G'HHHHHHHr   rZ   N)r   r   r   r   r   r   )
__future__r   typingr   r   r   r   urllib.parser   langchain_core.embeddingsr	   pydanticr
   r   r   r   rZ   r%   r   r   <module>rc      s    " " " " " " , , , , , , , , , , , , ! ! ! ! ! ! 0 0 0 0 0 0 + + + + + + + +" " " "
E? E? E? E? E?z9 E? E? E?PI I I I I- I I I I Ir   