sumit1703 commited on
Commit
c489c3a
·
verified ·
1 Parent(s): 06094f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -61,10 +61,20 @@ class GAIAAgent:
61
  def __init__(self):
62
  hf_token = os.environ.get("HF_TOKEN")
63
  model_id = os.environ.get("GAIA_MODEL_ID") # optional override
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
- model_kwargs = {}
66
- if hf_token:
67
- model_kwargs["token"] = hf_token
68
  if model_id:
69
  model_kwargs["model_id"] = model_id
70
  model = InferenceClientModel(**model_kwargs)
 
61
  def __init__(self):
62
  hf_token = os.environ.get("HF_TOKEN")
63
  model_id = os.environ.get("GAIA_MODEL_ID") # optional override
64
+ provider = os.environ.get("GAIA_PROVIDER", "hf-inference") # optional override
65
+
66
+ # Fail fast and loud instead of letting all 20 questions die silently
67
+ # at Step 1 with a generic "api_key" error from deep inside smolagents.
68
+ print(f"HF_TOKEN present: {bool(hf_token)}")
69
+ if not hf_token:
70
+ raise RuntimeError(
71
+ "HF_TOKEN is not set in this process. Go to Space Settings > "
72
+ "Variables and secrets and confirm a secret named exactly "
73
+ "HF_TOKEN exists, then restart the Space (adding a secret does "
74
+ "not always hot-reload a running container)."
75
+ )
76
 
77
+ model_kwargs = {"token": hf_token, "provider": provider}
 
 
78
  if model_id:
79
  model_kwargs["model_id"] = model_id
80
  model = InferenceClientModel(**model_kwargs)