Refer the very first block of code, where we extract ‘HF_API_KEY’ value from os.environ
I get an error: KeyError: ‘HF_API_KEY’
When I print os.environ, in my jupyter notebook it does not contain this key…however, I did notice that when I run the block of code on deeplearning site, it runs just fine!
Please advise why is this happening and how can I run this on my jupyter notebook on my machine
I’m guessing this API was created for things to run on the platform only, which is why you can’t use it locally. Let me double check this and get back to you.
I understand the confusion this has caused, I’m surprised to see that this was not mentioned in this particular course. However, in the other short courses, it is mentioned how you can use your own API key. (And to answer your original query), the HF_API_KEY has been setup within the environment of the course, which is why it works on the platform, but the fails when you run it locally, as you don’t have the exact same environment in your local system.
This Hugging face hfapi git should help you run your own HF API.
I went to the link in your note and ran the following:
import hfapi
client = hfapi.Client()
‘client’ variable seems to have the api key as I can run the various tasks…however, I am still wondering how can I set it up in my environment so I can pass api keys and endpoint url (HF_API_KEY, ENDPOINT_URL=os.environ[‘HF_API_ITT_BASE’]) from my os.environ
I’m afraid I can’t help you much with this, as I’m not familiar with these methods. I’m only doing google searches at this point. I found these two articles, this and this which might be helpful.
I’d suggest the same, the internet is a vast source of information. Whatever questions you have, you can google them or ChatGPT them and you’ll be able to find help.
I was also confused by this. I think the instructions in the notebook could be a little clearer.
The first line of the markdown says load in HF API key- so I went looking to create a key on HF’s website and substituted that (and it didn’t work because I think I created the wrong key but I digress)…it might be clearer to say load in the API key that has been pre-set as an environment variable for you as when I printed it I realised there was one already.