
    hq                        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y)    )annotationsN)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)	BaseModelc                  L    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<   y)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        h/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/llms/mlflow_ai_gateway.pyr   r      s1    3KOS- $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]paramsc                    t        j                  dt               	 dd l}t        |   di | | j                  r&|j                  j                  | j                         y y # t        $ r}t	        d      |d }~ww xY w)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)selfkwargsmlflowe	__class__s       r   r.   zMlflowAIGateway.__init__/   s    T	
	! 	"6"NN**4+;+;<   	H 	s   A# #	A=,A88A=c                    | j                   | j                  d| j                  r| j                  j                         }|S i }|S )N)r$   r#   )r$   r#   r%   dict)r1   r%   s     r   _default_paramszMlflowAIGateway._default_params@   sR      ++ZZ"
 &*[[t{{!"

  79"

 r   c                    | j                   S )N)r8   r1   s    r   _identifying_paramsz#MlflowAIGateway._identifying_paramsI   s    ###r   c                `   	 dd l }d|i| j                  r| j                  j                         ni }|xs$ | j                  r| j                  j                  nd x}r||d<   |j
                  j                  | j                  |      }	|	d   d   d   S # t        $ r}t        d      |d }~ww xY w)Nr   r'   promptr   )data
candidatestext)r+   r,   r%   r7   r   r/   queryr#   )
r1   r=   r   run_managerr2   r3   r4   r>   sresps
             r   _callzMlflowAIGateway._callM   s    	! f 
%)[[t{{!b 
 Ddkk$++**tE1EDL~~##DJJT#:L!!$V,,  	H 	s   B 	B-B((B-c                     y)Nzmlflow-ai-gatewayr   r:   s    r   	_llm_typezMlflowAIGateway._llm_typee   s    "r   )r2   r   )returnzDict[str, Any])rH   zMapping[str, Any])NN)
r=   r"   r   r   rB   z"Optional[CallbackManagerForLLMRun]r2   r   rH   r"   )rH   r"   )r   r   r   r   r   r$   r%   r.   propertyr8   r;   rE   rG   __classcell__)r5   s   @r   r!   r!      s    & J!%K%#F#="   $ $ %):>	-- "- 8	-
 - 
-0 # #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>rP      s6    "  5 5 = 3 
%Yg %P#c P#r   