401 Client Error: Unauthorized for url: https://huggingface.co/api/whoami-v2

I am trying to access my model using ChatHuggingFace(llm=llm), however it is giving constant error. I have added images for details.
I have access to the particular model as I am able to access it using langchain chains but there is some problem with ChatHuggingFace it seems.
Please help!

1 Like

Here is the code:
from langchain_core.messages import (
HumanMessage,
SystemMessage,
)
from langchain_huggingface import ChatHuggingFace

messages = [
SystemMessage(content=“You’re a helpful assistant”),
HumanMessage(
content=“What happens when an unstoppable force meets an immovable object?”
),
]

chat_model = ChatHuggingFace(llm=llm)

1 Like

did you fix it?