RayMelius Claude Sonnet 4.6 commited on
Commit
a01ef38
·
1 Parent(s): edea8c5

Fix HF provider switch: don't raise at init if HF_TOKEN missing

Browse files

HFInferenceClient.__init__ no longer raises ValueError when token is absent.
Logs a warning instead; complete() already returns "" gracefully.
Allows switching to HF models from the UI even without a token configured.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. src/soci/engine/llm.py +1 -4
src/soci/engine/llm.py CHANGED
@@ -976,10 +976,7 @@ class HFInferenceClient:
976
  or os.environ.get("HF_API_TOKEN", "")
977
  )
978
  if not self.api_key:
979
- raise ValueError(
980
- "No HuggingFace token found. Set HF_TOKEN (or HUGGINGFACE_TOKEN) "
981
- "to a token with 'Inference Providers (Write)' permission."
982
- )
983
  self.default_model = default_model
984
  self.max_retries = max_retries
985
  self.usage = LLMUsage()
 
976
  or os.environ.get("HF_API_TOKEN", "")
977
  )
978
  if not self.api_key:
979
+ logger.warning("HF_TOKEN not set — HF inference will be unavailable until token is configured")
 
 
 
980
  self.default_model = default_model
981
  self.max_retries = max_retries
982
  self.usage = LLMUsage()