anky2002 commited on
Commit
5388980
·
verified ·
1 Parent(s): ae25c7c

Upload agents/semantic_agent.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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) # 3s, 6s backoff
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}"