
    Ng                        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ed	
          Z G d de          ZdS )    )annotationsN)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)	BaseModelc                  N    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        f/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/llms/mlflow_ai_gateway.pyr   r      s_         33KO- $D$$$$ $J$$$$$$r   r   allow)extrac                       e Zd ZU dZded<   dZded<   dZded<   d fdZedd            Z	edd            Z
	 	 dddZedd            Z x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                   t          j        dt                     	 dd l}n"# t          $ r}t	          d          |d }~ww xY w t                      j        di | | j        r!|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$   gatewayset_gateway_uri)selfr&   mlflowe	__class__s       r   r/   zMlflowAIGateway.__init__/   s    T	
 	
 	
	!!!!! 	 	 	H  	 	""6""" 	=N**4+;<<<<<	= 	=s   " 
A<AreturnDict[str, Any]c                h    | j         | j        d| j        r| j                                        ni }|S )N)r$   r#   )r$   r#   r%   dict)r2   r%   s     r   _default_paramszMlflowAIGateway._default_params@   sF      +Z"
 "
 &*[8t{!!!b"

 r   Mapping[str, Any]c                    | j         S )N)r:   r2   s    r   _identifying_paramsz#MlflowAIGateway._identifying_paramsI   s    ##r   promptr   r   run_manager"Optional[CallbackManagerForLLMRun]c                D   	 dd l }n"# t          $ r}t          d          |d }~ww xY wd|i| j        r| j                                        ni }|p| j        r| j        j        nd x}r||d<   |j                            | j        |          }	|	d         d         d         S )Nr   r(   r?   r   )data
candidatestext)r,   r-   r%   r9   r   r0   queryr#   )
r2   r?   r   r@   r&   r3   r4   rC   sresps
             r   _callzMlflowAIGateway._callM   s    	!!!!! 	 	 	H  	 f 
%)[8t{!!!b 
 DdkC$+**tE1 	DL~##DJT#::L!!$V,,s    
&!&c                    dS )Nzmlflow-ai-gatewayr   r=   s    r   	_llm_typezMlflowAIGateway._llm_typee   s    ""r   )r&   r   )r6   r7   )r6   r;   )NN)
r?   r"   r   r   r@   rA   r&   r   r6   r"   )r6   r"   )r   r   r   r   r   r$   r%   r/   propertyr:   r>   rI   rK   __classcell__)r5   s   @r   r!   r!      s          & JJJ!%K%%%%#F####= = = = = ="    X $ $ $ X$ %):>	- - - - -0 # # # X# # # # #r   r!   )
__future__r   r)   typingr   r   r   r   r   langchain_core.callbacksr	   #langchain_core.language_models.llmsr
   pydanticr   r   r!   r   r   r   <module>rS      s    " " " " " "  5 5 5 5 5 5 5 5 5 5 5 5 5 5 = = = = = = 3 3 3 3 3 3      
% % % % %Yg % % % %P# P# P# P# P#c P# P# P# P# P#r   