File “C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\llms\huggingface_hub.py”, line 112, in _call
raise ValueError(f"Error raised by inference API: {response[‘error’]}")
ValueError: Error raised by inference API: Authorization header is correct, but the token seems invalid
yes
i created the env. and placed the token in it…
then i called it this way: os.environ[“HUGGINGFACEHUB_API_TOKEN”] = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
Hello, I am following an introductory video from youtube titled:
Hugging Face + Langchain in 5 mins | Access 200k+ FREE AI models for your AI apps
Everything seems to work well, but I encountered this error message related to the bearer token: {“error”:“Authorization header is correct, but the token seems invalid”}
I already tried by creating another token but the error continues.
If anybody could find a solution I would be very grateful.
from huggingface_hub import login
login(config['huggingface_api'])
import getpass
from transformers import HfAgent
agent_star = HfAgent(
"https://api-inference.huggingface.co/models/bigcode/starcoder"
)
text = "this is new building with 14 storeys painted green."
storey_1 = agent_star.run("What is the number of storeys?", text=text)
yet i’m getting the following error message
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 341, in run
result = self.generate_one(prompt, stop=["Task:"])
File "c:\Users\tolu.olusooto\Documents\Nakina\.venv\lib\site-packages\transformers\tools\agents.py", line 649, in generate_one
raise ValueError(f"Error {response.status_code}: {response.json()}")
ValueError: Error 400: {'error': 'Authorization header is correct, but the token seems invalid'}
profile > settings > Access Tokens
Create a new Access Token with WRITE permission and use that new token. Changing the permission on an already existing token doesn’t seem to work. Just create a new token.