
    dhq                        S SK Jr  S SKrS SKJrJrJrJrJr  S SK	J
r
  S SKJr  S SKJr   " S S\S	S
9r " S S\5      rg)    )annotationsN)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)	BaseModelc                  T    \ rS rSr% SrSrS\S'   SrS\S'    S	rS
\S'   S	r	S\S'   Sr
g	)Params   z)Parameters for the MLflow AI Gateway LLM.g        floattemperature   intcandidate_countNOptional[List[str]]stopzOptional[int]
max_tokens )__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r   __static_attributes__r       b/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/mlflow_ai_gateway.pyr   r      s1    3KOS- $D
$ $J$r   r   allow)extrac                     ^  \ rS rSr% SrS\S'   SrS\S'   SrS\S	'   SU 4S
 jjr\	SS j5       r
\	SS j5       r  S         SS jjr\	SS j5       rSrU =r$ )MlflowAIGateway   a  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                  > [         R                  " S[        5         SS Kn[
        TU ]  " S0 UD6  U R                  (       a&  UR                  R                  U R                  5        g g ! [         a  n[	        S5      UeS nAff = f)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    r2   MlflowAIGateway.__init__/   s    T	
	! 	"6"NN**4+;+;<   	H 	s   A* *
B4B  Bc                    U R                   U R                  S.U R                  (       a  U R                  R                  5       EnU$ 0 EnU$ )N)r(   r'   )r(   r'   r)   dict)r5   r)   s     r    _default_paramsMlflowAIGateway._default_params@   sR      ++ZZ"
 &*[[t{{!"

  79"

 r   c                    U R                   $ )N)r=   r5   s    r    _identifying_params#MlflowAIGateway._identifying_paramsI   s    ###r   c                    SS K nSU0U R                  (       a  U R                  R                  5       O0 EnU=(       d)    U R                  (       a  U R                  R                  OS =n(       a  XS'   UR
                  R                  U R                  US9n	U	S   S   S   $ ! [         a  n[        S5      UeS nAff = f)Nr   r+   promptr   )data
candidatestext)r/   r0   r)   r<   r   r3   queryr'   )
r5   rD   r   run_managerr6   r7   r8   rE   sresps
             r    _callMlflowAIGateway._callM   s    	! f 
%)[[t{{!b 
 Ddkk$++**tE1EL~~##DJJT#:L!!$V,,  	H 	s   B# #
B>-B99B>c                    g)Nzmlflow-ai-gatewayr   r@   s    r    	_llm_typeMlflowAIGateway._llm_typee   s    "r   r   )r6   r   )returnzDict[str, Any])rQ   zMapping[str, Any])NN)
rD   r&   r   r   rI   z"Optional[CallbackManagerForLLMRun]r6   r   rQ   r&   )rQ   r&   )r   r   r   r   r   r   r(   r)   r2   propertyr=   rA   rL   rO   r   __classcell__)r9   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>rY      s6    "  5 5 = 3 
%Yg %P#c P#r   