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

Upload 34 files

Browse files
Files changed (2) hide show
  1. DEPLOY.md +13 -8
  2. src/llm_client.py +8 -6
DEPLOY.md CHANGED
@@ -75,14 +75,19 @@ real LLM responses:
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
 
 
75
  picks up new secrets on the next restart).
76
 
77
  **Note on the API endpoint:** `src/llm_client.py` explicitly passes
78
+ `provider="auto"` to `InferenceClient`, and `requirements.txt` pins a
79
+ recent `huggingface_hub` version. Both matter:
80
+ - Older client versions / omitting the provider can silently route calls
81
+ through the now-deprecated `api-inference.huggingface.co` domain, which
82
+ fails with a DNS resolution error rather than a clear auth error.
83
+ - Hardcoding a specific provider (e.g. `"hf-inference"`) can fail with
84
+ *"Model not supported by provider ..."* for models that are actually
85
+ hosted via a different backend (Together, Fireworks, Novita, SambaNova,
86
+ etc.) under HF's Inference Providers system. `provider="auto"` lets HF's
87
+ router pick whichever backend actually serves each candidate model.
88
+
89
+ If you ever see errors in the "Test LLM connection" diagnostics, they'll
90
+ show you exactly which of the above it is per candidate model.
91
 
92
  ## Re-training / updating the models
93
 
src/llm_client.py CHANGED
@@ -34,8 +34,10 @@ from src.retriever import KBRetriever, RetrievedDoc
34
  # LLM_MODEL_ID is set as an env var, it is tried first, ahead of this list.
35
  MODEL_CANDIDATES = [
36
  "Qwen/Qwen2.5-7B-Instruct",
 
37
  "meta-llama/Llama-3.2-3B-Instruct",
38
  "mistralai/Mistral-7B-Instruct-v0.3",
 
39
  "HuggingFaceH4/zephyr-7b-beta",
40
  ]
41
 
@@ -125,12 +127,12 @@ def answer_query(
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():
 
34
  # LLM_MODEL_ID is set as an env var, it is tried first, ahead of this list.
35
  MODEL_CANDIDATES = [
36
  "Qwen/Qwen2.5-7B-Instruct",
37
+ "meta-llama/Llama-3.1-8B-Instruct",
38
  "meta-llama/Llama-3.2-3B-Instruct",
39
  "mistralai/Mistral-7B-Instruct-v0.3",
40
+ "microsoft/Phi-3.5-mini-instruct",
41
  "HuggingFaceH4/zephyr-7b-beta",
42
  ]
43
 
 
127
  errors = []
128
  for candidate in MODEL_CANDIDATES:
129
  try:
130
+ # provider="auto" (the huggingface_hub default) lets HF's Inference
131
+ # Providers router pick whichever backend (hf-inference, Together,
132
+ # Fireworks, Novita, SambaNova, etc.) actually serves this specific
133
+ # model -- hardcoding a single provider caused "model not supported
134
+ # by provider X" errors for models hosted elsewhere.
135
+ client = InferenceClient(model=candidate, token=hf_token, provider="auto")
136
  completion = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=0.3)
137
  text = completion.choices[0].message.content
138
  if text and text.strip():