Error in Unit 3 Agentic Rag

#6
by rohilrao - opened

The HF Space developed for this unit fails with a runtime error.

I am getting the same error.

same here, something related to an authentication error, at least for me

I think the hf token stored in the settings is invalidated or expired.
I suggest to clone the space and add your own HF token.

The code is OK. I was able to clone the repo and run it successfully using my personal HF Read token

The code runs fine, In my case, my space tokens were misconfigured.

steps to fix

  1. Create new read token https://huggingface.co/settings/tokens
    with permissions:
    Read access to contents of all repos under your personal namespace
    Read access to contents of all public gated repos you can access
    Make calls to Inference Providers
    Make calls to your Inference Endpoints

  2. Set your token so the code can use it
    Settings > scroll down to "Variables and secrets"

  • Important -> delete any other old secrets if exist
  • add new secret
    name it HUGGINGFACEHUB_API_TOKEN and add the token value

Hi, @alisamak -- thank you for posting the instructions. I'm new to Spaces and testing to find my way. I removed the Read-access criteria from your suggestion and had functionality. Any tips as to why you'd want to include these? Thanks

Hi @makinuh -- I'm new to spaces too, in my case I had this setting as default, so thats why I included it in the answer, but I agree it probably might work without this permission.

@alisamak Thank you for the steps. My issue was around the old token. Once I created a new token and cloned the space as a Public space, things started working.

I think the quickest and most correct way to fix the problem is to use the user's Access Token value when performing a Space duplicate operation

2025-05-04_13-58.png

Can confirm that what @uuidenny mentioned works - just duplicate the space using your own HF Token and everything should run fine

Just for fun - another user ( @Data-Gem ) has provided an extended invitee list that you can use by going into the retriever.py file and swapping out this line :

FROM
guest_dataset = datasets.load_dataset("agents-course/unit3-invitees", split="train")

TO
guest_dataset = datasets.load_dataset("Data-Gem/agents-course-unit3-invitees-expanded", split="train")

Just for fun - another user ( @Data-Gem ) has provided an extended invitee list that you can use by going into the retriever.py file and swapping out this line :

FROM
guest_dataset = datasets.load_dataset("agents-course/unit3-invitees", split="train")

TO
guest_dataset = datasets.load_dataset("Data-Gem/agents-course-unit3-invitees-expanded", split="train")

I think you could adding https://huggingface.co/datasets/agents-course/unit3-invitees to your collection and edit the data as you need, then change in the code base for correct link

2025-05-06_23-39.png

The code runs fine, In my case, my space tokens were misconfigured.

steps to fix

  1. Create new read token https://huggingface.co/settings/tokens
    with permissions:
    Read access to contents of all repos under your personal namespace
    Read access to contents of all public gated repos you can access
    Make calls to Inference Providers
    Make calls to your Inference Endpoints

  2. Set your token so the code can use it
    Settings > scroll down to "Variables and secrets"

  • Important -> delete any other old secrets if exist
  • add new secret
    name it HUGGINGFACEHUB_API_TOKEN and add the token value

I have tried to follow you instruction, first of all I could not find any "Variables and secrets" in settings. then I anyhow created new space and it did not solve the issue.
it would be great if you can share where can I find the "Variables and secrets"?

Hello @Obiabanaki12 ! You need to perform the following actions:

  1. Go to the settings section of your Space.
  2. Scroll down the webpage and in the "Variables and secrets" section, edit the value or add a new one.
    settings.png
    secrets.png

Sign up or log in to comment