Open avargasestay opened 2 months ago
Believe this will be fixed by #23821 - will take a look if @Jofthomas doesn't have time!
Believe this will be fixed by #23821 - will take a look if @Jofthomas doesn't have time!
Hey @efriis, thanks for your answer! Looking at #23821 I don't think it'll solve the issue because that PR is improving the huggingface_token
management inside HuggingFaceEndpoint
and as I mentioned in the description, the HuggingFaceEndpoint
works as expected with a localhost endpoint_url
.
I strongly believe the problem is inside ChatHuggingFace
as it is reaching line 458 (calling list_inference_endpoints("*")
from huggingface_hub
) when it shouldn't do it as the inference endpoint is served locally using TGI.
You are right @avargasestay , My PR draft does not solve this issue. I'll provide a fix in my next commit. Thanks for bringing it to me.
@Jofthomas I don't see any PR's yet to solve this issue. Have you worked on it already? Was thinking of doing the commit otherwise.
Not yet, but with the recent reworks of the inferenceClient, I'll do a refresher in langchain-huggingface code this weekend.
Has there been any progress on this? I am currently stuck on the same issue.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Traceback (most recent call last): .venv/lib/python3.10/site-packages/langchain_huggingface/chat_models/huggingface.py", line 320, in init self._resolve_model_id()
.venv/lib/python3.10/site-packages/langchain_huggingface/chat_models/huggingface.py", line 458, in _resolve_model_id available_endpoints = list_inference_endpoints("*")
.venv/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 7081, in list_inference_endpoints user = self.whoami(token=token)
.venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs)
.venv/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 1390, in whoami headers=self._build_hf_headers(
.venv/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 8448, in _build_hf_headers return build_hf_headers(
.venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs)
.venv/lib/python3.10/site-packages/huggingface_hub/utils/_headers.py", line 124, in build_hf_headers token_to_send = get_token_to_send(token)
.venv/lib/python3.10/site-packages/huggingface_hub/utils/_headers.py", line 158, in get_token_to_send raise LocalTokenNotFoundError(
huggingface_hub.errors.LocalTokenNotFoundError: Token is required (
token=True
), but no token found. You need to provide a token or be logged in to Hugging Face withhuggingface-cli login
orhuggingface_hub.login
. See https://huggingface.co/settings/tokens.Description
langchain_huggingface
library to connect to a TGI instance served locally. The problem is when wrapping aHuggingFaceEndpoint
intoChatHuggingFace
, it raises error requesting user token to be provided when it shouldn't be necessary a token when the model has already being downloaded and is serving locally.model_id
parameter to theChatHuggingFace
doesn't avoid falling in the following case:I was able to solve the issue by modifying the constructor method so when providing the
model_id
it doesn't resolve it:I imagine there is a better way to solve this, for example by adding some logic to check if the
endpoint_url
is a valid ip to request or if it is served with TGI or simply by checking if it's localhost:System Info
System Information
Package Information