
    dhU                    v    S SK J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KJrJr   " S S\5      rg	)
    )annotations)AnyDictListMappingOptional)urlparse)CallbackManagerForLLMRun)LLM)FieldPrivateAttrc                  &  ^  \ rS rSr% SrS\S'    S\S'    SrS\S'    S	rS
\S'    SrS\S'    Sr	S\S'    \
" \S9rS\S'     \" 5       rS\S'   SU 4S jjrSS 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$ )$Mlflow   a  MLflow LLM service.

To use, you should have the `mlflow[genai]` python package installed.
For more information, see https://mlflow.org/docs/latest/llms/deployments.

Example:
    .. code-block:: python

        from langchain_community.llms import Mlflow

        completions = Mlflow(
            target_uri="http://localhost:5000",
            endpoint="test",
            temperature=0.1,
        )
strendpoint
target_urig        floattemperature   intnNOptional[List[str]]stopzOptional[int]
max_tokens)default_factoryDict[str, Any]extra_paramsr   _clientc                   > [         TU ]  " S0 UD6  U R                  5          SSKJn  U" U R
                  5      U l        g ! [         a  n[        S5      UeS nAff = f)Nr   )get_deploy_clientzeFailed to create the client. Please run `pip install mlflow[genai]` to install required dependencies. )super__init___validate_urimlflow.deploymentsr!   r   r   ImportError)selfkwargsr!   e	__class__s       W/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/mlflow.pyr$   Mlflow.__init__/   s^    "6"		<,T__=DL 	) 		s   A 
AAAc                    U R                   S:X  a  g / SQn[        U R                   5      R                  U;  a  [        SU R                    SU S35      eg )N
databricks)httphttpsr/   zInvalid target URI: z. The scheme must be one of .)r   r	   scheme
ValueError)r(   alloweds     r,   r%   Mlflow._validate_uri=   s\    ??l*1DOO$++7:&t&7 8--4IQ8  ;    c                    U R                   U R                  U R                  U R                  U R                  U R
                  U R                  S.$ )Nr   r   r   r   r   r   r   r9   r(   s    r,   _default_paramsMlflow._default_paramsG   sC     //++II// --
 	
r7   c                    U R                   $ )N)r;   r:   s    r,   _identifying_paramsMlflow._identifying_paramsS   s    ###r7   c                (   UU R                   U R                  S.U R                  EUEnU R                  =(       d    U=n(       a  X%S'   U R                  b  U R                  US'   U R
                  R                  U R                  US9nUS   S   S   $ )N)promptr   r   r   r   )r   inputschoicesr   text)r   r   r   r   r   r   predictr   )r(   rA   r   run_managerr)   dataresps          r,   _callMlflow._callW   s     ++ 
 	 

  
 99$$4$L??&!%D||##T]]4#HIq!&))r7   c                    g)Nmlflowr"   r:   s    r,   	_llm_typeMlflow._llm_typem   s    r7   )r   )r)   r   )returnNone)rO   r   )rO   zMapping[str, Any])NN)
rA   r   r   r   rF   z"Optional[CallbackManagerForLLMRun]r)   r   rO   r   )rO   r   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   dictr   r   r   r$   r%   propertyr;   r>   rI   rM   __static_attributes____classcell__)r+   s   @r,   r   r      s    " MO K#AsJ7 $D
$ $J$3#(#>L.>71=GS  	
 	
 $ $ %):>	** "* 8	*
 * 
*,  r7   r   N)
__future__r   typingr   r   r   r   r   urllib.parser	   langchain_core.callbacksr
   langchain_core.language_modelsr   pydanticr   r   r   r"   r7   r,   <module>ra      s(    " 5 5 ! = . 'dS dr7   