a
    bg	                     @   s   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 edddd	Zdee eee  ed
ddZG dd de	ZdS )    )AnyCallableListMappingOptional)CallbackManagerForLLMRun)LLM)Field)enforce_stop_tokensN)promptreturnc                 C   s   t d|   dS )z&Displays the given prompt to the user.
N)print)r    r   l/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/llms/human.py_display_prompt
   s    r   )	separatorstopr   c                    sN   | pd} g }t    sq@|  |rt fdd|D rq@q| |}|S )z3Collects and returns user input as a single string.r   c                 3   s   | ]}| v V  qd S Nr   ).0seqliner   r   	<genexpr>       z&_collect_user_input.<locals>.<genexpr>)inputappendanyjoin)r   r   linesZmulti_line_inputr   r   r   _collect_user_input   s    

r    c                   @   s   e Zd ZU dZedd dZeed< edd dZee	gdf ed< d	Z
e	ed
< i Zee	ef ed< i Zee	ef ed< eee	ef dddZee	dddZde	eee	  ee ee	dddZdS )HumanInputLLMzUser input as the response.c                   C   s   t S r   )r    r   r   r   r   <lambda>&   r   zHumanInputLLM.<lambda>)default_factory
input_funcc                   C   s   t S r   )r   r   r   r   r   r"   '   r   Nprompt_funcr   r   input_kwargsprompt_kwargs)r   c                 C   s   i S )zU
        Returns an empty dictionary as there are no identifying parameters.
        r   selfr   r   r   _identifying_params,   s    z!HumanInputLLM._identifying_paramsc                 C   s   dS )zReturns the type of LLM.zhuman-inputr   r(   r   r   r   	_llm_type3   s    zHumanInputLLM._llm_type)r   r   run_managerkwargsr   c                 K   sD   | j |fi | j | jf | j|d| j}|dur@t||}|S )a~  
        Displays the prompt to the user and returns their input as a response.

        Args:
            prompt (str): The prompt to be displayed to the user.
            stop (Optional[List[str]]): A list of stop strings.
            run_manager (Optional[CallbackManagerForLLMRun]): Currently not used.

        Returns:
            str: The user's input as a response.
        )r   r   N)r%   r'   r$   r   r&   r
   )r)   r   r   r,   r-   Z
user_inputr   r   r   _call8   s    
zHumanInputLLM._call)NN)__name__
__module____qualname____doc__r	   r$   r   __annotations__r%   strr   r&   r   r   r'   propertyr*   r+   r   r   r   r.   r   r   r   r   r!   #   s&   
   
r!   )NN)typingr   r   r   r   r   Zlangchain_core.callbacksr   Z#langchain_core.language_models.llmsr   Zpydanticr	   Zlangchain_community.llms.utilsr
   r4   r   r    r!   r   r   r   r   <module>   s    