Skip to content

Commit

Permalink
Fix method name which changes in tutorial (#34252)
Browse files Browse the repository at this point in the history
The method `model_download_tool` was called `model_download_counter` earlier in the tutorial, this raises an error when following the code.
  • Loading branch information
andimarafioti authored Oct 21, 2024
1 parent f701b98 commit 32590b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/source/en/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ This code can quickly be converted into a tool, just by wrapping it in a functio
from transformers import tool

@tool
def model_download_counter(task: str) -> str:
def model_download_tool(task: str) -> str:
"""
This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub.
It returns the name of the checkpoint.
Expand All @@ -345,7 +345,7 @@ def model_download_counter(task: str) -> str:
```

The function needs:
- A clear name. The name usually describes what the tool does. Since the code returns the model with the most downloads for a task, let's put `model_download_counter`.
- A clear name. The name usually describes what the tool does. Since the code returns the model with the most downloads for a task, let's put `model_download_tool`.
- Type hints on both inputs and output
- A description, that includes an 'Args:' part where each argument is described (without a type indication this time, it will be pulled from the type hint).
All these will be automatically baked into the agent's system prompt upon initialization: so strive to make them as clear as possible!
Expand All @@ -367,7 +367,7 @@ You get the following:
======== New task ========
Can you give me the name of the model that has the most downloads in the 'text-to-video' task on the Hugging Face Hub?
==== Agent is executing the code below:
most_downloaded_model = model_download_counter(task="text-to-video")
most_downloaded_model = model_download_tool(task="text-to-video")
print(f"The most downloaded model for the 'text-to-video' task is {most_downloaded_model}.")
====
```
Expand Down

0 comments on commit 32590b5

Please sign in to comment.