def execute_app_spoke(self, query, shared_data_dict, requested_app, flag=False):
        """
        Execute a Spoke to solve a step.

        Args:
            query (str): The user query.
            shared_data_dict (dict): Shared data dictionary.
            requested_app (str): The app to execute.
            flag (bool): Default to False.

        Returns:
            str: The result of the spoke execution.

        """
        # Check whether the Spoke exists
        if requested_app in self.spoke_tool:
            print("Using " + requested_app + " spoke ...\n")
            # Use the existing Spoke to solve this step
            session_id = uuid.uuid4()
            spoke_id = self.spoke_tool[requested_app]["id"]
            spoke_session_id = (
                self.user_id + ":" + str(spoke_id) + ":" + str(session_id)
            )
            spoke = self.spoke_tool[requested_app]["spoke"]

            if shared_data_dict:
                action_message = (
                    f'Your data "{shared_data_dict}" is sharing with "{requested_app}"'
                )
                data_consent = get_user_consent(
                    self.user_id, requested_app, action_message, False, "data"
                )
                if not data_consent:
                    shared_data_dict = None

            # Create sockets
            parent, child = socket.socketpair()
            parent_sock = Socket(parent)
            child_sock = Socket(child)

            if shared_data_dict:
                shared_data = [
                    ChatMessage(
                        role=MessageRole.USER,
                        content=("Data shared by the user:" + str(shared_data_dict)),
                    ),
                ]
            else:
                shared_data = None

            p = multiprocessing.Process(
                target=spoke.run_process,
                args=(child_sock, query, spoke_session_id, shared_data),
            )
            p.start()
            results = self.handle_request(parent_sock)
            p.join(timeout=TIMEOUT)
            child.close()
            return results

        elif requested_app == "":
            # Create a dedicated Spoke to route the query
            # Create sockets
            parent, child = socket.socketpair()
            parent_sock = Socket(parent)
            child_sock = Socket(child)

            collab_functionalities = self.tool_importer.get_collab_functions()

            session_id = uuid.uuid4()
            spoke_session_id = (
                self.user_id + ":" + str(self.spoke_counter) + ":" + str(session_id)
            )
            spoke = Spoke(tools=[], collab_functions=collab_functionalities)
            self.spoke_counter += 1

            if shared_data_dict:
                shared_data = [
                    ChatMessage(
                        role=MessageRole.USER,
                        content=("Data shared by the user:" + str(shared_data_dict)),
                    ),
                ]
            else:
                shared_data = None

            p = multiprocessing.Process(
                target=spoke.run_process,
                args=(child_sock, query, spoke_session_id, shared_data),
            )
            p.start()
            results = self.handle_request(parent_sock)
            p.join(timeout=TIMEOUT)
            child.close()
            return results

        else:
            # Create a new Spoke to solve this step
            # get the tool object based on the tool name
            print("Using " + requested_app + " spoke ...\n")
            tool = next(t for t in self.tools if t.metadata.name == requested_app)

            collab_functionalities = self.tool_importer.get_collab_functions(
                requested_app
            )

            # Create sockets
            parent, child = socket.socketpair()
            parent_sock = Socket(parent)
            child_sock = Socket(child)

            session_id = uuid.uuid4()
            spoke_session_id = (
                self.user_id + ":" + str(self.spoke_counter) + ":" + str(session_id)
            )
            self.spoke_tool[requested_app] = {
                "id": self.spoke_counter,
                "spoke": Spoke(tools=[tool], collab_functions=collab_functionalities),
                "tool": tool,
            }
            self.spoke_counter += 1

            spoke = self.spoke_tool[requested_app]["spoke"]

            if shared_data_dict:
                action_message = (
                    f'Your data "{shared_data_dict}" is sharing with "{requested_app}"'
                )
                data_consent = get_user_consent(
                    self.user_id, requested_app, action_message, False, "data"
                )
                if not data_consent:
                    shared_data_dict = None

            if shared_data_dict:
                shared_data = [
                    ChatMessage(
                        role=MessageRole.USER,
                        content=("Data shared by the user:" + str(shared_data_dict)),
                    ),
                ]
            else:
                shared_data = None

            p = multiprocessing.Process(
                target=spoke.run_process,
                args=(child_sock, query, spoke_session_id, shared_data),
            )
            p.start()
            results = self.handle_request(parent_sock)
            p.join(timeout=TIMEOUT)
            child.close()
            return results

        Execute a Spoke to solve a step.

        Args:
            query (str): The user query.
            shared_data_dict (dict): Shared data dictionary.
            requested_app (str): The app to execute.
            flag (bool): Default to False.

        Returns:
            str: The result of the spoke execution.

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