Error on HF but not in Colab - SOLVED

Calling this agent generates an error on my HF Space but not in Google Colab:

ask the question

context = get_context_from_text()

question = question1
myanswer =“Answer the question in question using the context in context”, question=question, context=context)
st.write(f"Question: {question}“)
st.write(f” Answer: {myanswer}")

ValueError: Error 400: {‘error’: ‘Authorization header is correct, but the token seems invalid’}

I’m using the StarCoder model. The only difference between the Colab and HF versions is that I login to HF from Colab. Trying to login to HF from a Space generates an error. I have verified that both the ‘question’ and the ‘context’ are valid. Why am I getting an error on HF but not Colab? Thanks.

Closed. I wasn’t accessing the token environmental value correctly. Now I am and it works fine.

1 Like

Hi there, please give an example of how to access the token the right way. Having the same error currently

1 Like