Pro-Coder commited on
Commit
439fe44
·
verified ·
1 Parent(s): 8f9afd8

Upload 34 files

Browse files
Files changed (3) hide show
  1. DEPLOY.md +10 -0
  2. requirements.txt +1 -1
  3. src/llm_client.py +6 -1
DEPLOY.md CHANGED
@@ -74,6 +74,16 @@ real LLM responses:
74
  4. Restart the Space (**Settings → Factory reboot**, or just wait — it
75
  picks up new secrets on the next restart).
76
 
 
 
 
 
 
 
 
 
 
 
77
  ## Re-training / updating the models
78
 
79
  The Space **loads pre-built artifacts** from `models/` and `data/` — it
 
74
  4. Restart the Space (**Settings → Factory reboot**, or just wait — it
75
  picks up new secrets on the next restart).
76
 
77
+ **Note on the API endpoint:** `src/llm_client.py` explicitly passes
78
+ `provider="hf-inference"` to `InferenceClient`, and `requirements.txt`
79
+ pins a recent `huggingface_hub` version. Both matter: older client
80
+ versions / omitting the provider can silently route calls through the
81
+ now-deprecated `api-inference.huggingface.co` domain, which fails with a
82
+ DNS resolution error rather than a clear auth error. If you ever see a
83
+ `NameResolutionError` mentioning `api-inference.huggingface.co` in the
84
+ "Test LLM connection" diagnostics, bump `huggingface_hub` in
85
+ `requirements.txt` to the latest release.
86
+
87
  ## Re-training / updating the models
88
 
89
  The Space **loads pre-built artifacts** from `models/` and `data/` — it
requirements.txt CHANGED
@@ -4,5 +4,5 @@ pandas==2.2.3
4
  numpy==1.26.4
5
  matplotlib==3.9.2
6
  joblib==1.4.2
7
- huggingface_hub==0.26.5
8
  spaces>=0.30.0
 
4
  numpy==1.26.4
5
  matplotlib==3.9.2
6
  joblib==1.4.2
7
+ huggingface_hub==0.31.4
8
  spaces>=0.30.0
src/llm_client.py CHANGED
@@ -125,7 +125,12 @@ def answer_query(
125
  errors = []
126
  for candidate in MODEL_CANDIDATES:
127
  try:
128
- client = InferenceClient(model=candidate, token=hf_token)
 
 
 
 
 
129
  completion = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=0.3)
130
  text = completion.choices[0].message.content
131
  if text and text.strip():
 
125
  errors = []
126
  for candidate in MODEL_CANDIDATES:
127
  try:
128
+ # `provider="hf-inference"` forces routing through HF's current
129
+ # Inference Providers router (router.huggingface.co). Without it,
130
+ # older huggingface_hub versions / ambiguous setups can fall back
131
+ # to the deprecated `api-inference.huggingface.co` endpoint,
132
+ # which has been sunset and fails with a DNS resolution error.
133
+ client = InferenceClient(model=candidate, token=hf_token, provider="hf-inference")
134
  completion = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=0.3)
135
  text = completion.choices[0].message.content
136
  if text and text.strip():