Hermes Bot commited on
Commit
f42c3c8
·
unverified ·
1 Parent(s): f438be9

fix: resolve base_url and model conflict in InferenceClient

Browse files

Omit the model parameter from the constructor and pass the direct
model-specific serverless API endpoint as base_url. This forces the
use of the free serverless Inference API and resolves the conflict.

Files changed (1) hide show
  1. shared/inference_client.py +4 -2
shared/inference_client.py CHANGED
@@ -103,10 +103,12 @@ class InferenceResult:
103
  def _get_client():
104
  """Lazy-load the InferenceClient to keep boot fast."""
105
  from huggingface_hub import InferenceClient
 
 
 
106
  return InferenceClient(
107
- model=INFERENCE_MODEL,
108
  token=HF_TOKEN,
109
- base_url="https://api-inference.huggingface.co",
110
  )
111
  def generate(
112
  project: str,
 
103
  def _get_client():
104
  """Lazy-load the InferenceClient to keep boot fast."""
105
  from huggingface_hub import InferenceClient
106
+ # By passing the model-specific serverless endpoint as base_url and omitting the model param,
107
+ # we force huggingface_hub to use the free serverless API instead of the paid router.huggingface.co.
108
+ model_endpoint = f"https://api-inference.huggingface.co/models/{INFERENCE_MODEL}"
109
  return InferenceClient(
110
+ base_url=model_endpoint,
111
  token=HF_TOKEN,
 
112
  )
113
  def generate(
114
  project: str,