Open morgandiverrez opened 1 week ago
I tested it on my machine and faced not issues???
here is the following detailed stack :
So everyone using HuggingFaceEndpoint without Hugging Face token configured in environment variable will have the same issue.
Do you have the same understanding of this stack ?
I suggest that we introduce sentinelle value as the default value in get_from_env
I can push a pull request for it
Good catch, I'm also experiencing this issue, this makes it impossible to use any custom deployment of HF TGI, that doesn't required any HF token (and login).
Introducing a sentinel value may be considered as a breaking change, get_from_env
will then accept None
as default value without raising any exception which is currently not accepted 🤔. This would assume that users rely on this exception being raised, which I my opinion shouldn't be considered as "nominal" usage of this method.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
File "/home/Morgan.Diverrez/code/GitHub/tock-arkea/gen-ai/orchestrator-server/src/main/python/server/src/gen_ai_orchestrator/services/langchain/factories/llm/hugging_face_tgi_llm_factory.py", line 41, in get_language_model return HuggingFaceEndpoint( File "/home/Morgan.Diverrez/code/GitHub/tock-arkea/gen-ai/orchestrator-server/src/main/python/server/.venv/lib/python3.9/site-packages/pydantic/v1/main.py", line 341, in init raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for HuggingFaceEndpoint root Did not find huggingfacehub_api_token, please add an environment variable
HUGGINGFACEHUB_API_TOKEN
which contains it, or passhuggingfacehub_api_token
as a named parameter. (type=value_error)Description
After PR #23309 a few months ago, when we leave huggingfacehub_api_token at its default value, None, and do not set the environment variable HF_TOKEN or HUGGINGFACEHUB_API_TOKEN, the
get_from_dict_or_env
function at lines 197 and 201 also has a default value of None, similar to huggingfacehub_api_token. Theget_from_dict_or_env
function callsget_from_env
, which raises an error if no token is set in the environment variable.Therefore, we need to use another solution to retrieve environment variables.
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)