Skip to content

Commit

Permalink
Improve logging (#3) (#30254)
Browse files Browse the repository at this point in the history
* Add custom errors, improve logging
  • Loading branch information
aymeric-roucher authored Apr 23, 2024
1 parent 8787d9d commit 91e50ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/transformers/tools/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"""
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/tools/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down

0 comments on commit 91e50ef

Please sign in to comment.