Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
commit
Vasek Mlejnskyccbdb754a815
diff --cc api-service/codegen/agent/base.pyindex f13dc2ce0,9d1c04829..d86ff875a--- a/api-service/codegen/agent/base.py+++ b/api-service/codegen/agent/base.py@@@ -304,80 -237,3 +241,83 @@@ class CodegenAgentExecutor(AgentExecutocolor_mapping=color_mapping,)return output, observation++<<<<<<< HEAD++ def _take_next_step(+ self,+ name_to_tool_map: Dict[str, BaseTool],+ color_mapping: Dict[str, str],+ inputs: Dict[str, str],+ intermediate_steps: List[Tuple[AgentAction, str]],+ ) -> Union[AgentFinish, Tuple[AgentAction, str]]:+ """Take a single step in the thought-action-observation loop.++ Override this to take control of how the agent makes and acts on choices.+ """+ # Call the LLM to see what to do.+ output = self.agent.plan(intermediate_steps, **inputs)++ # If the tool chosen is the finishing tool, then we end and return.+ if isinstance(output, AgentFinish):+ return output+ # Sometimes the LLM decides to pass the value of `FINAL_ANSWER_ACTION` as a tool name.+ # Instead of trying to "force" the LLM to don't do that, we can just write a bit of+ # code and handle this case.+ elif (+ output.tool == FINAL_ANSWER_ACTION+ or output.tool == FINAL_ANSWER_ACTION_NO_WHITESPACE+ ):+ return AgentFinish({"output": output.tool_input}, output.log)++ # Sometimes the agent just completely messed up the output format.+ # We want to remind it that the last answer was wrong and it should+ # follow the format.+ if output.tool == MALFORMED_ANSWER:+ return output, output.tool_input++ self.callback_manager.on_agent_action(+ output, verbose=self.verbose, color="green"+ )++ # The `ACTIONS_QUEUE` isn't really a name of a tool.+ # It's a way for us to specify that the LLM passed multiple actions in a single response.+ # We handle this case by running each action one by one.+ if output.tool == ACTIONS_QUEUE:+ observation = ""++ # The `output.tool_input` is a raw action string+ actions = parse_action_string(output.tool_input)++ # Go through each action and run it.+ # Collect outputs from each action.+ for action in actions:+ tool_name = action.attrib["tool"]+ tool_input = action.text+ observation = self._run_tool(+ tool_name=tool_name,+ tool_input=tool_input,+ name_to_tool_map=name_to_tool_map,+ color_mapping=color_mapping,+ )+ # observation = (+ # observation+ # + f"Output of action '{tool_name}':\n"+ # + self._run_tool(+ # tool_name=tool_name,+ # tool_input=tool_input,+ # name_to_tool_map=name_to_tool_map,+ # color_mapping=color_mapping,+ # )+ # + "==="+ # )++ else:+ observation = self._run_tool(+ tool_name=output.tool,+ tool_input=output.tool_input,+ name_to_tool_map=name_to_tool_map,+ color_mapping=color_mapping,+ )+ return output, observation++=======++>>>>>>> 3c7509f0f283209afea1f99ce636f6dfcb74d242