o
    Zh                     @  s|   d dl mZ d dlZd dlmZmZmZmZmZ d dl	m
Z
 d dlmZ d dlmZ G dd ded	d
ZG dd deZdS )    )annotationsN)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)	BaseModelc                   @  sD   e Zd ZU dZdZded< dZded< 	 dZd	ed
< dZded< dS )Paramsz)Parameters for the MLflow AI Gateway LLM.g        floattemperature   intcandidate_countNOptional[List[str]]stopzOptional[int]
max_tokens)	__name__
__module____qualname____doc__r   __annotations__r   r   r    r   r   a/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/llms/mlflow_ai_gateway.pyr      s   
 r   Zallow)extrac                      s~   e Zd ZU dZded< dZded< dZded< d fddZedddZ	edddZ
		d d!ddZed"ddZ  ZS )#MlflowAIGatewaya7  MLflow AI Gateway LLMs.

    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.llms import MlflowAIGateway

            completions = MlflowAIGateway(
                gateway_uri="<your-mlflow-ai-gateway-uri>",
                route="<your-mlflow-ai-gateway-completions-route>",
                params={
                    "temperature": 0.1
                }
            )
    strrouteNzOptional[str]gateway_urizOptional[Params]params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 )NzF`MlflowAIGateway` is deprecated. Use `Mlflow` or `Databricks` 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MlflowAIGateway.__init__returnDict[str, Any]c                 C  s,   | j | jd| jr| j }|S i }|S )N)r   r   )r   r   r    dict)r+   r    r   r   r   _default_params@   s   zMlflowAIGateway._default_paramsMapping[str, Any]c                 C  s   | j S )N)r3   r+   r   r   r   _identifying_paramsI   s   z#MlflowAIGateway._identifying_paramspromptr   r   run_manager"Optional[CallbackManagerForLLMRun]c           
   
   K  s   zdd l }W n ty } ztd|d }~ww d|i| jr#| j ni }|p0| jr/| jjnd  }r7||d< |jj| j|d}	|	d d d S )Nr   r"   r7   r   )data
candidatestext)r&   r'   r    r2   r   r*   queryr   )
r+   r7   r   r8   r!   r,   r-   r:   srespr   r   r   _callM   s$   zMlflowAIGateway._callc                 C  s   dS )Nzmlflow-ai-gatewayr   r5   r   r   r   	_llm_typee   s   zMlflowAIGateway._llm_type)r!   r   )r0   r1   )r0   r4   )NN)
r7   r   r   r   r8   r9   r!   r   r0   r   )r0   r   )r   r   r   r   r   r   r    r)   propertyr3   r6   r@   rA   __classcell__r   r   r.   r   r      s   
 r   )
__future__r   r#   typingr   r   r   r   r   Zlangchain_core.callbacksr   Z#langchain_core.language_models.llmsr	   Zpydanticr
   r   r   r   r   r   r   <module>   s    
