Skip to content

Commit 91e50ef

Browse files
Improve logging (#3) (#30254)
* Add custom errors, improve logging
1 parent 8787d9d commit 91e50ef

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/transformers/tools/agents.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def load_tools_if_needed(self, remote=False):
271271
self._tools[name] = load_tool(task_or_repo_id, remote=_remote)
272272

273273

274-
class AgentError(Exception):
274+
class AgentError(RuntimeError):
275275
"""Base class for other agent-related exceptions"""
276276
def __init__(self, message):
277277
super().__init__(message)
@@ -336,7 +336,6 @@ def __init__(
336336
self.prompt = None
337337
self.logs = []
338338

339-
340339
@property
341340
def toolbox(self) -> Dict[str, Tool]:
342341
"""Get the toolbox currently available to the agent"""

src/transformers/tools/prompts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def download_prompt(prompt_or_repo_id, agent_name, mode="run"):
160160
161161
ALWAYS provide a 'Thought:' and an 'Action:' sequence. You MUST provide at least the 'Action:' sequence to move forward.
162162
You can use the result of the previous action as input for the next action.
163-
The observation will always be a string: it can represent a file, like "imag_1.jpg".
163+
The observation will always be a string: it can represent a file, like "image_1.jpg".
164164
Then you can use it as input for the next action. You can do it for instance as follows:
165165
166166
Observation: "image_1.jpg"
@@ -172,6 +172,7 @@ def download_prompt(prompt_or_repo_id, agent_name, mode="run"):
172172
}
173173
174174
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:
175+
175176
Action:
176177
{
177178
"action": "final_answer",

0 commit comments

Comments
 (0)