o
    ZhS
                     @  sd   d dl mZ d dlZd dlmZmZmZmZ d dlm	Z	 d dl
mZ dddZG dd de	eZdS )    )annotationsN)AnyIteratorListOptional)
Embeddings)	BaseModeltexts	List[str]sizeintreturnIterator[List[str]]c                 c  s.    t dt| |D ]}| |||  V  q	d S Nr   )rangelen)r	   r   i r   d/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/embeddings/mlflow_gateway.py_chunk
   s   r   c                      sZ   e Zd ZU dZded< 	 dZded< 	 d fd	d
ZdddZdddZdddZ	  Z
S )MlflowAIGatewayEmbeddingsa  MLflow AI Gateway embeddings.

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

    Example:
        .. code-block:: python

            from langchain_community.embeddings import MlflowAIGatewayEmbeddings

            embeddings = MlflowAIGatewayEmbeddings(
                gateway_uri="<your-mlflow-ai-gateway-uri>",
                route="<your-mlflow-ai-gateway-embeddings-route>"
            )
    strrouteNzOptional[str]gateway_urikwargsr   c              
     sj   t dt zdd l}W n ty } ztd|d }~ww t jdi | | jr3|j	| j d S d S )Nzd`MlflowAIGatewayEmbeddings` is deprecated. Use `MlflowEmbeddings` or `DatabricksEmbeddings` instead.r   _Could not import `mlflow.gateway` module. Please install it with `pip install mlflow[gateway]`.r   )
warningswarnDeprecationWarningmlflow.gatewayImportErrorsuper__init__r   gatewayZset_gateway_uri)selfr   mlflowe	__class__r   r   r"   %   s$   z"MlflowAIGatewayEmbeddings.__init__r	   r
   r   List[List[float]]c              
   C  s   zdd l }W n ty } ztd|d }~ww g }t|dD ]%}|jj| jd|id}t|d d tr=||d  q|	|d  q|S )Nr   r      text)data
embeddings)
r   r    r   r#   queryr   
isinstancer   extendappend)r$   r	   r%   r&   r-   txtrespr   r   r   _query7   s"   z MlflowAIGatewayEmbeddings._queryc                 C  s
   |  |S )Nr4   )r$   r	   r   r   r   embed_documentsK   s   
z)MlflowAIGatewayEmbeddings.embed_documentsr+   List[float]c                 C  s   |  |gd S r   r5   )r$   r+   r   r   r   embed_queryN   s   z%MlflowAIGatewayEmbeddings.embed_query)r   r   )r	   r
   r   r)   )r+   r   r   r7   )__name__
__module____qualname____doc____annotations__r   r"   r4   r6   r8   __classcell__r   r   r'   r   r      s   
 

r   )r	   r
   r   r   r   r   )
__future__r   r   typingr   r   r   r   Zlangchain_core.embeddingsr   Zpydanticr   r   r   r   r   r   r   <module>   s    
