diff --git a/src/transformers/tools/agents.py b/src/transformers/tools/agents.py index 78b26cf7cd84e7..f23805cab9cffe 100644 --- a/src/transformers/tools/agents.py +++ b/src/transformers/tools/agents.py @@ -271,7 +271,7 @@ def load_tools_if_needed(self, remote=False): self._tools[name] = load_tool(task_or_repo_id, remote=_remote) -class AgentError(Exception): +class AgentError(RuntimeError): """Base class for other agent-related exceptions""" def __init__(self, message): super().__init__(message) @@ -336,7 +336,6 @@ def __init__( self.prompt = None self.logs = [] - @property def toolbox(self) -> Dict[str, Tool]: """Get the toolbox currently available to the agent""" diff --git a/src/transformers/tools/prompts.py b/src/transformers/tools/prompts.py index 95a6b0eec9fa97..ad0566435aaffe 100644 --- a/src/transformers/tools/prompts.py +++ b/src/transformers/tools/prompts.py @@ -160,7 +160,7 @@ def download_prompt(prompt_or_repo_id, agent_name, mode="run"): ALWAYS provide a 'Thought:' and an 'Action:' sequence. You MUST provide at least the 'Action:' sequence to move forward. You can use the result of the previous action as input for the next action. -The observation will always be a string: it can represent a file, like "imag_1.jpg". +The observation will always be a string: it can represent a file, like "image_1.jpg". Then you can use it as input for the next action. You can do it for instance as follows: Observation: "image_1.jpg" @@ -172,6 +172,7 @@ def download_prompt(prompt_or_repo_id, agent_name, mode="run"): } To provide the final answer to the task, use an action blob with "action": "final_answer" tool. It is the only way to complete the task, else you will be stuck on a loop. So your final output should look like this: + Action: { "action": "final_answer",