Spaces:
Sleeping
Sleeping
colesr Claude Opus 4.7 (1M context) commited on
Commit ·
4e85bc2
1
Parent(s): bc5a64b
Copilot: show billing-specific hint on HF Inference 402
Browse filesThe generic 'check your token / try another model' hint was actively
misleading when the real cause was depleted credits. Detect 402 /
Payment Required / 'depleted' in the exception text and point at
https://huggingface.co/settings/billing instead.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
app.py
CHANGED
|
@@ -1240,11 +1240,20 @@ def run_copilot_turn(user_message, chat_history, trace, proposals, df, hf_token,
|
|
| 1240 |
temperature=0.3,
|
| 1241 |
)
|
| 1242 |
except Exception as e:
|
| 1243 |
-
|
| 1244 |
-
|
| 1245 |
-
|
| 1246 |
-
|
| 1247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1248 |
hit_step_cap = False
|
| 1249 |
break
|
| 1250 |
|
|
|
|
| 1240 |
temperature=0.3,
|
| 1241 |
)
|
| 1242 |
except Exception as e:
|
| 1243 |
+
err_text = str(e)
|
| 1244 |
+
is_402 = "402" in err_text or "Payment Required" in err_text or "depleted" in err_text.lower()
|
| 1245 |
+
if is_402:
|
| 1246 |
+
hint = (
|
| 1247 |
+
"💡 Your Hugging Face Inference credits are exhausted. "
|
| 1248 |
+
"Subscribe to HF PRO or add pre-paid credits at "
|
| 1249 |
+
"https://huggingface.co/settings/billing, then retry."
|
| 1250 |
+
)
|
| 1251 |
+
else:
|
| 1252 |
+
hint = (
|
| 1253 |
+
f"💡 Confirm your HF token is valid and that `{model}` supports tool calling. "
|
| 1254 |
+
f"Try one of: {', '.join(AGENT_FALLBACK_MODELS)}."
|
| 1255 |
+
)
|
| 1256 |
+
final_text = f"❌ Copilot error: {type(e).__name__}: {e}\n\n{hint}"
|
| 1257 |
hit_step_cap = False
|
| 1258 |
break
|
| 1259 |
|