o
    Zh	                     @   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 deddfd	d
Z	ddee deee  defddZG dd de	ZdS )    )AnyCallableListMappingOptional)CallbackManagerForLLMRun)LLM)Field)enforce_stop_tokenspromptreturnNc                 C   s   t d|   dS )z&Displays the given prompt to the user.
N)print)r    r   U/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/llms/human.py_display_prompt
   s   r   	separatorstopc                    sP   | pd} g }	 t    sn|  |r t fdd|D r nq| |}|S )z3Collects and returns user input as a single string.r   Tc                 3   s    | ]}| v V  qd S Nr   ).0seqliner   r   	<genexpr>   s    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dee	ef fddZede	fddZ		dde	deee	  dee dede	f
ddZdS )HumanInputLLMzUser input as the response.c                   C      t S r   )r   r   r   r   r   <lambda>&       zHumanInputLLM.<lambda>)default_factory
input_funcc                   C   r!   r   )r   r   r   r   r   r"   '   r#   Nprompt_funcr   r   input_kwargsprompt_kwargsr   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_typer   r   run_managerkwargsc                 K   sD   | j |fi | j | jd| 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   Nr   )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    #   s0   
  
r    r0   )typingr   r   r   r   r   Zlangchain_core.callbacksr   Z#langchain_core.language_models.llmsr   Zpydanticr	   Zlangchain_community.llms.utilsr
   r6   r   r   r    r   r   r   r   <module>   s    

