Transformers Agent
Hello, I am experimenting with the new Transformer Agents, and I wrote the following script, which I copied from an example:# load tools
from transformers.tools import HfAgent
import textract

# load sample pdf document
text = textract.process("/content/sample_data/TechNation.pdf").decode("utf-8")

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

# instruct agent
agent.run("What is `text` about?", text=text)But I get the following error when I run my script:ValueError                                Traceback (most recent call last)
<ipython-input-25-9fe5f4eb9747> in <cell line: 2>()
      1 # instruct agent
----> 2 agent.run("What is `text` about?", text=text)

1 frames
/usr/local/lib/python3.10/dist-packages/transformers/tools/agents.py in generate_one(self, prompt, stop)
    486             return self._generate_one(prompt)
    487         elif response.status_code != 200:
--> 488             raise ValueError(f"Error {response.status_code}: {response.json()}")
    489 
    490         result = response.json()[0]["generated_text"]

ValueError: Error 400: {'error': 'Authorization header is correct, but the token seems invalid'}Please, what can I do about it? Thanks!
2023-05-12T21:02:44Z
from huggingface_hub import login
#Do this before HfAgent() and it should work
login("<your HF token>")
2023-05-15T14:08:06Z
Hi, thanks for offering your suggestion, which worked. Thanks again! However, while the code runs without breaking, I am being asked to define “labels” in my code. I guess I have not defined the right tool for the task. I am doing a document search, but I do not find where in the Transformer Agents docs that explains how to define labels. Please, I would appreciate it if you point me in the right direction. Thanks!