
    NgU                    ~    d dl m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 d dlmZmZ  G d de          Zd	S )
    )annotations)AnyDictListMappingOptional)urlparse)CallbackManagerForLLMRun)LLM)FieldPrivateAttrc                       e Zd ZU dZded<   	 ded<   	 dZded<   	 dZd	ed
<   	 dZded<   	 dZded<   	  e	e
          Zded<   	 	  e            Zded<   d" fdZd#dZed$d            Zed%d            Z	 	 d&d'd Zed(d!            Z xZS ))Mlflowa  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   _clientkwargsc                     t                      j        di | |                                  	 ddlm}  || j                  | _        d S # t          $ r}t          d          |d }~ww xY w)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)selfr   r!   e	__class__s       [/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/llms/mlflow.pyr$   zMlflow.__init__/   s    ""6"""		<<<<<<,,T_==DLLL 	 	 	)  		s   A 
A,A''A,returnNonec                    | j         dk    rd S g d}t          | j                   j        |vrt          d| j          d| d          d S )N
databricks)httphttpsr/   zInvalid target URI: z. The scheme must be one of .)r   r	   scheme
ValueError)r(   alloweds     r+   r%   zMlflow._validate_uri=   sv    ?l**F111DO$$+7::8t 8 8-48 8 8   ;:    c                \    | j         | j        | j        | j        | j        | j        | j        dS )Nr   r   r   r   r   r   r   r8   r(   s    r+   _default_paramszMlflow._default_paramsG   s8     /+I/ -
 
 	
r6   Mapping[str, Any]c                    | j         S )N)r:   r9   s    r+   _identifying_paramszMlflow._identifying_paramsS   s    ##r6   promptrun_manager"Optional[CallbackManagerForLLMRun]c                    || j         | j        d| j        |}| j        p|x}r||d<   | j        
| j        |d<   | j                            | j        |          }|d         d         d         S )N)r>   r   r   r   r   )r   inputschoicesr   text)r   r   r   r   r   r   predictr   )r(   r>   r   r?   r   dataresps          r+   _callzMlflow._callW   s     + 
  
 	 

  
 9$$4 	 DL?&!%D|##T]4#HHIq!&))r6   c                    dS )Nmlflowr"   r9   s    r+   	_llm_typezMlflow._llm_typem   s    xr6   )r   r   )r,   r-   )r,   r   )r,   r;   )NN)
r>   r   r   r   r?   r@   r   r   r,   r   )r,   r   )__name__
__module____qualname____doc____annotations__r   r   r   r   r   dictr   r   r   r$   r%   propertyr:   r=   rH   rK   __classcell__)r*   s   @r+   r   r      s         " MMMOOO K#AJJJJ7 $D$$$$ $J$$$$3#(5#>#>#>L>>>>71;==G             	
 	
 	
 X	
 $ $ $ X$ %):>	* * * * *,    X    r6   r   N)
__future__r   typingr   r   r   r   r   urllib.parser	   langchain_core.callbacksr
   langchain_core.language_modelsr   pydanticr   r   r   r"   r6   r+   <module>rZ      s    " " " " " " 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ! ! ! ! ! ! = = = = = = . . . . . . ' ' ' ' ' ' ' 'd d d d dS d d d d dr6   