name: "PlanWriter"
description: "Generates plan with interactions with the user"

_target_: flow_modules.aiflows.PlanWriterFlowModule.PlanWriterFlow.instantiate_from_default_config

input_interface:
  - "goal"
  - "memory_files"

output_interface:
  - "plan"
  - "status"
  - "summary"

### Subflows specification
subflows_config:
  Controller:
    _target_: flow_modules.aiflows.PlanWriterFlowModule.PlanWriterCtrlFlow.instantiate_from_default_config
    backend:
      api_infos: ???
      model_name:
        openai: gpt-4
        azure: azure/gpt-4

  Executor:
    _target_: aiflows.base_flows.BranchingFlow.instantiate_from_default_config
    subflows_config:
      write_plan:
        _target_: flow_modules.aiflows.InteractivePlanGenFlowModule.InteractivePlanGenFlow.instantiate_from_default_config
        subflows_config:
          PlanGenerator:
            _target_: flow_modules.aiflows.PlanGeneratorFlowModule.PlanGeneratorAtomicFlow.instantiate_from_default_config
            backend:
              api_infos: ???
              model_name:
                openai: gpt-4
                azure: azure/gpt-4

          PlanFileEditor:
            _target_: flow_modules.aiflows.PlanFileEditFlowModule.PlanFileEditAtomicFlow.instantiate_from_default_config

          ParseFeedback:
            _target_: flow_modules.aiflows.ParseFeedbackFlowModule.ParseFeedbackAtomicFlow.instantiate_from_default_config
            input_interface:
              - "temp_plan_file_location"
            output_interface:
              - "plan"
              - "feedback"

      ask_user:
        _target_: flow_modules.aiflows.PlanWriterFlowModule.PlanWriterAskUserFlow.instantiate_from_default_config


early_exit_key: "EARLY_EXIT"

topology:
  - goal: "Select the next action and prepare the input for the executor."
    input_interface:
      _target_: aiflows.interfaces.KeyInterface
      additional_transformations:
        - _target_: aiflows.data_transformations.KeyMatchInput
    flow: Controller
    output_interface:
      _target_: PlanWriterFlow.detect_finish_or_continue
    reset: false

  - goal: "Execute the action specified by the Controller."
    input_interface:
      _target_: aiflows.interfaces.KeyInterface
      keys_to_rename:
        command: branch
        command_args: branch_input_data
      keys_to_select: ["branch", "branch_input_data"]
    flow: Executor
    output_interface:
      _target_: aiflows.interfaces.KeyInterface
      keys_to_rename:
        branch_output_data.plan: plan
        branch_output_data.feedback: feedback
        branch_output_data.temp_plan_file_location: temp_plan_file_location
      keys_to_delete: ["branch_output_data"]
    reset: false