# Table of Contents * [Structure of PlanWriterFlow](#structure-of-planwriterflow) * [run\_planwriter](#run_planwriter) * [PlanWriterAskUserFlow](#PlanWriterAskUserFlow) * [PlanWriterAskUserFlow](#PlanWriterAskUserFlow.PlanWriterAskUserFlow) * [run](#PlanWriterAskUserFlow.PlanWriterAskUserFlow.run) * [PlanWriterFlow](#PlanWriterFlow) * [PlanWriterFlow](#PlanWriterFlow.PlanWriterFlow) * [detect\_finish\_or\_continue](#PlanWriterFlow.PlanWriterFlow.detect_finish_or_continue) * [run](#PlanWriterFlow.PlanWriterFlow.run) * [\_\_init\_\_](#__init__) * [PlanWriterCtrlFlow](#PlanWriterCtrlFlow) * [PlanWriterCtrlFlow](#PlanWriterCtrlFlow.PlanWriterCtrlFlow) * [\_\_init\_\_](#PlanWriterCtrlFlow.PlanWriterCtrlFlow.__init__) * [instantiate\_from\_config](#PlanWriterCtrlFlow.PlanWriterCtrlFlow.instantiate_from_config) * [run](#PlanWriterCtrlFlow.PlanWriterCtrlFlow.run) # Structure of PlanWriterFlow ``` goal | v +---------------+ | Controller | --------<<<<-----------+ +---------------+ | | | | (command, command args) | | | v | +------------------+ | | Executor | Each branch is an | | (Tree Structure) | executor | +------------------+ | | ^ | (summary) | | | v | | | +-> goes back to the Controller>-+ ``` Structure of the Executors: ``` +-------------------+ | Branching | | Executor | +-------------------+ / \ / \ / \ / \ write_plan ask_user ``` About the branches: - [ask_user](https://huggingface.co/aiflows/PlanWriterFlowModule/blob/main/PlanWriterAskUserFlow.py): Ask user for info / confirmation, etc. - [write_plan](https://huggingface.co/aiflows/InteractivePlanGenFlowModule): Generates plan (user edit is allowed) and fetches user feedback. How it works: Controller calls write_plan until user is satisfied in the feedback, finish. # run\_planwriter # PlanWriterAskUserFlow ## PlanWriterAskUserFlow Objects ```python class PlanWriterAskUserFlow(HumanStandardInputFlow) ``` Refer to: https://huggingface.co/aiflows/ExtendLibraryFlowModule/blob/main/ExtLibAskUserFlow.py This flow is used to ask the user a question and get a response. *Input Interface*: - `question` *Output Interface*: - `feedback` - `plan` *Configuration Parameters*: - `query_message_prompt_template`: The message template to prompt the user for input. - `request_multi_line_input_flag`: Whether to request multi-line input from the user. - `end_of_input_string`: The string to enter to indicate the end of input. #### run ```python def run(input_data: Dict[str, Any]) -> Dict[str, Any] ``` Run the flow module. **Arguments**: - `input_data` (`Dict[str, Any]`): The input data to the flow module. **Returns**: `Dict[str, Any]`: The output data from the flow module. # PlanWriterFlow ## PlanWriterFlow Objects ```python class PlanWriterFlow(ContentWriterFlow) ``` This flow inherits from ContentWriterFlow. In the subflow of the executor, we specify the InteractivePlanGenFlow (https://huggingface.co/aiflows/InteractivePlanGenFlowModule) *Input Interface*: - `goal` *Output Interface*: - `plan` - `result` - `summary` - `status` *Configuration Parameters*: - Also refer to superclass ContentWriterFlow (https://huggingface.co/aiflows/ContentWriterFlowModule) - `input_interface`: the input interface of the flow - `output_interface`: the output interface of the flow - `subflows_config`: the configuration of the subflows - `early_exit_key`: the key in the flow state that indicates the early exit condition - `topology`: the topology of the flow #### detect\_finish\_or\_continue ```python @CircularFlow.output_msg_payload_processor def detect_finish_or_continue(output_payload: Dict[str, Any], src_flow) -> Dict[str, Any] ``` This function is called when the subflow finishes running. configured in the topology of the subflow config. **Arguments**: - `output_payload` (`Dict[str, Any]`): the output payload of the subflow - `src_flow` (`Flow`): the subflow that generates the output payload **Returns**: `Dict[str, Any]`: the processed output payload #### run ```python def run(input_data: Dict[str, Any]) -> Dict[str, Any] ``` This function runs the flow. **Arguments**: - `input_data` (`Dict[str, Any]`): the input data of the flow **Returns**: `Dict[str, Any]`: the output data of the flow # \_\_init\_\_ # PlanWriterCtrlFlow ## PlanWriterCtrlFlow Objects ```python class PlanWriterCtrlFlow(ChatAtomicFlow) ``` Refer to: https://huggingface.co/aiflows/JarvisFlowModule/blob/main/Controller_JarvisFlow.py This flow is a controller flow that controls the PlanWriterFlow. *Input Interface Non Initialized*: - `goal`: str *Input Interface Initialized*: - `feedback`: str - `goal`: str - `plan`: str *Output Interface*: - `command`: str - `command_args`: Dict[str, Any] *Configuration Parameters*: - `input_interface_non_initialized`: List[str] = ["goal"] - `input_interface_initialized`: List[str] = ["feedback", "goal", "plan"] - `output_interface`: List[str] = ["command", "command_args"] - `backend`: Dict[str, Any] : backend of the LLM - `commands`: List[Dict[str, Any]] : commands that the LLM can execute - `system_message_prompt_template`: str : the template of the system message prompt - `init_human_message_prompt_template`: str : the template of the initial human message prompt - `human_message_prompt_template`: str : the template of the human message prompt - `previous_messages`: Dict[str, Any] : the previous messages of the conversation (sliding window) #### \_\_init\_\_ ```python def __init__(commands: List[Command], **kwargs) ``` This function initializes the flow. **Arguments**: - `commands` (`List[Command]`): List[Command] : commands that the LLM can execute - `kwargs` (`Dict[str, Any]`): other parameters #### instantiate\_from\_config ```python @classmethod def instantiate_from_config(cls, config) ``` This function instantiates the flow from the config. **Arguments**: - `config` (`Dict[str, Any]`): the config of the flow **Returns**: `ChatAtomicFlow`: the instantiated flow #### run ```python def run(input_data: Dict[str, Any]) -> Dict[str, Any] ``` This function runs the flow. **Arguments**: - `input_data` (`Dict[str, Any]`): the input data **Returns**: `Dict[str, Any]`: the output of the flow