Transformers Agents
# Introducing Transformers Agents

This PR adds a new API called Transformers Agents. Agents allow you to use Transformers with zero code experience, directly talking to Transformers or Diffusers via natural language. It is based on `Agent`s and `Tool`s. The agent is an LLM prompted to generate code using the tools, which are simple functions performing a single task.

Tools can live in Transformers or on the Hub, this PR introduces both. You can read more about this in the added documentation but here is an example:

Define an agent using the starcoder model:
```py
from transformers import HfAgent

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
```

Use the command `run` to execute a given problem:
```py
agent.run("Draw me a picture of rivers and lakes")
```

![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes.png)

Use the command `chat` to chat with the agent and execute instructions one after the other:

```py
agent.chat("Draw me a picture of rivers and lakes")
```

![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes.png)

```py
agent.chat("Transform the picture so that there is a rock in there")
```
![](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes_and_beaver.png)
_The documentation is not available anymore as the PR was closed or merged._<|||||>picture = agent.run("Draw me a picture of rivers and lakes")
==Explanation from the agent==
I will use the following  tool: `image_segmenter` to generate a segmentation mask for the image.


==Code generated by the agent==
prompt = "rivers and lakes"
mask = image_segmenter(image, prompt)


==Result==
Evaluation of the code stopped at line 1 before the end because of the following error:
The variable `image` is not defined.<|||||>Ah yes we did that example with openAI. Will fine-tune the prompt so that example works before the release, thanks for the pointer!