Spaces:
Sleeping
Sleeping
Hermes Bot commited on
fix: resolve base_url and model conflict in InferenceClient
Browse filesOmit 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.
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 |
-
|
| 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,
|