
    i                     ^    d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ  G d de      Zy	)
zIExecutor for Human nodes.

Runs the human-in-the-loop interaction nodes.
    )List)Node)HumanConfig)MessageMessageRole)NodeExecutorc                   0    e Zd ZdZdedee   dee   fdZy)HumanNodeExecutorz*Executor used for human interaction nodes.nodeinputsreturnc                    | j                          |j                  dk7  rt        d|j                   d      |j	                  t
              }|st        d|j                   d      |j                  }| j                  |      }| j                  j                         }|t        d      |j                  |j                  |xs d|ddi      }| j                  t        j                  |j                         |j                  	      gS )
zExecute a human node.
        
        Args:
            node: Human node definition
            inputs: Input messages
            
        Returns:
            Result supplied by the human reviewer
        humanzNode z is not a human nodez has no human configurationz?HumanPromptService is not configured; cannot execute human node 	node_type)r   metadata)source)_ensure_not_cancelledr   
ValueErrorid	as_configr   description_inputs_to_textcontextget_human_prompt_serviceRuntimeErrorrequest_build_messager   USERas_message_content)selfr   r   human_confighuman_task_description
input_dataprompt_serviceprompt_results           Q/Users/bowang/.openclaw/workspace/ChatDev/runtime/node/executor/human_executor.pyexecutezHumanNodeExecutor.execute   s    	""$>>W$uTWWI-ABCC~~k2uTWWI-HIJJ!-!9!9 ))&1
>>@!`aa&..GG"(b!7+	 / 
 ##,,.77 $ 
  	    N)__name__
__module____qualname____doc__r   r   r   r(    r)   r'   r
   r
      s'    4&D &$w- &DM &r)   r
   N)r-   typingr   entity.configsr   entity.configs.node.humanr   entity.messagesr   r   runtime.node.executor.baser   r
   r.   r)   r'   <module>r4      s'   
   1 0 3) )r)   