Upload agents/semantic_agent.py with huggingface_hub
Browse files- agents/semantic_agent.py +5 -1
agents/semantic_agent.py
CHANGED
|
@@ -53,8 +53,12 @@ def _vlm(img, sys_prompt, user_prompt):
|
|
| 53 |
except Exception as e:
|
| 54 |
last_error = e
|
| 55 |
if attempt < 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
import time
|
| 57 |
-
wait = 3 * (attempt + 1)
|
| 58 |
time.sleep(wait)
|
| 59 |
continue
|
| 60 |
return f"VLM_ERROR: {last_error}"
|
|
|
|
| 53 |
except Exception as e:
|
| 54 |
last_error = e
|
| 55 |
if attempt < 2:
|
| 56 |
+
err_str = str(last_error)
|
| 57 |
+
# Don't retry on payment/quota errors — it won't help
|
| 58 |
+
if '402' in err_str or 'credit' in err_str.lower() or 'quota' in err_str.lower():
|
| 59 |
+
return f"VLM_ERROR: Inference credits depleted. Add HF Pro subscription or purchase credits at huggingface.co/settings/billing"
|
| 60 |
import time
|
| 61 |
+
wait = 3 * (attempt + 1)
|
| 62 |
time.sleep(wait)
|
| 63 |
continue
|
| 64 |
return f"VLM_ERROR: {last_error}"
|