Exemplo n.º 1
0
    def process(self,
                command: State,
                ignore_threshold: bool,
                force_agent: str = None) -> Optional[Union[Action, List[Action]]]:
        if force_agent:
            plugin_instances = self.agent_datasource.get_instances(command.user_name, force_agent)
            ignore_threshold = True
        else:
            plugin_instances = self.agent_datasource.get_instances(command.user_name)

        candidate_actions = agent_executor.execute_agents(command, plugin_instances)

        suggested_command = self.select_best_candidate(command, plugin_instances, candidate_actions,
                                                       ignore_threshold, self._pre_exec_id)

        if not suggested_command:
            suggested_command = Action()

        self.store_pre_orchestrator_memory(command, plugin_instances, candidate_actions, ignore_threshold,
                                           suggested_command)


        if isinstance(suggested_command, Action):
            if not suggested_command.suggested_command:
                suggested_command.suggested_command = command.command
        else:
            for action in suggested_command:
                if not action.suggested_command:
                    action.suggested_command = command.command

        return suggested_command
Exemplo n.º 2
0
    def process_post(self, command: State,
                     ignore_threshold: bool) -> Optional[Action]:
        plugin_instances = self.agent_datasource.get_instances(
            command.user_name)
        candidate_actions = []
        for plugin_instance in plugin_instances:
            action_post_executed = plugin_instance.post_execute(command)
            action_post_executed.agent_owner = plugin_instance.agent_name
            if action_post_executed:
                candidate_actions.append(action_post_executed)

        suggested_command = self.select_best_candidate(command,
                                                       plugin_instances,
                                                       candidate_actions,
                                                       ignore_threshold,
                                                       self._post_exec_id)

        self.store_post_orchestrator_memory(command, plugin_instances,
                                            candidate_actions,
                                            ignore_threshold,
                                            suggested_command)

        if not suggested_command:
            suggested_command = Action()

        if not suggested_command.suggested_command:
            suggested_command.suggested_command = command.command

        return suggested_command