def filter_plan(self, plan):
        """
        Filter the plan based on available tools and group the steps.

        Args:
            plan (dict): The plan generated by the planner.

        """
        filtered_steps = [
            step for step in plan["steps"] if step["name"] in self.tool_names
        ]
        output_key_to_step = {}
        grouped_steps = []

        for step in filtered_steps:
            # Determine if the step is dependent on a previous step
            dependent = False
            for input_value in step["input"].values():
                if (
                    isinstance(input_value, str)
                    and input_value.startswith("<")
                    and input_value.endswith(">")
                ):
                    dependent_key = input_value[1:-1]
                    if dependent_key in output_key_to_step:
                        dependent = True
                        grouped_steps[output_key_to_step[dependent_key]].append(step)
                        break

            # If the step is not dependent on any previous step's output, start a new group
            if not dependent:
                grouped_steps.append([step])

            # Record the output key of this step
            if "output" in step:
                output_key_to_step[step["output"]] = len(grouped_steps) - 1

        self.plan = grouped_steps
        self.app_list = [
            [step["name"] for step in step_list] for step_list in self.plan
        ]
        self.app_data_dict = {
            step["name"]: step["input"] for step_list in self.plan for step in step_list
        }

        Filter the plan based on available tools and group the steps.

        Args:
            plan (dict): The plan generated by the planner.

        
llama-index-packs/llama-index-packs-secgpt/llama_index/packs/secgpt/hub_operator.py