a
    bg                     @  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                   @  sB   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   x/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/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	d
 fddZeddddZ	eddddZ
ddddd	ddddZed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]paramsr   )kwargsc              
     sr   t dt zdd l}W n. tyF } ztd|W Y d }~n
d }~0 0 t jf i | | jrn|j	| j 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]`.)
warningswarnDeprecationWarningmlflow.gatewayImportErrorsuper__init__r   gatewayZset_gateway_uri)selfr!   mlflowe	__class__r   r   r)   /   s    zMlflowAIGateway.__init__zDict[str, Any])returnc                 C  s&   | j | jd| jr| j ni }|S )N)r   r   )r   r   r    dict)r+   r    r   r   r   _default_params@   s    zMlflowAIGateway._default_paramszMapping[str, Any]c                 C  s   | j S )N)r2   r+   r   r   r   _identifying_paramsI   s    z#MlflowAIGateway._identifying_paramsr   z"Optional[CallbackManagerForLLMRun])promptr   run_managerr!   r0   c           
   
   K  s   zdd l }W n. ty: } ztd|W Y d }~n
d }~0 0 d|i| jrR| j ni }|pl| jrj| jjnd  }rz||d< |jj| j|d}	|	d d d S )Nr   r"   r5   r   )data
candidatestext)r&   r'   r    r1   r   r*   queryr   )
r+   r5   r   r6   r!   r,   r-   r7   srespr   r   r   _callM   s     zMlflowAIGateway._callc                 C  s   dS )Nzmlflow-ai-gatewayr   r3   r   r   r   	_llm_typee   s    zMlflowAIGateway._llm_type)NN)r   r   r   r   r   r   r    r)   propertyr2   r4   r=   r>   __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   
