Update app.py
Browse files
app.py
CHANGED
|
@@ -8,16 +8,9 @@ import gradio as gr
|
|
| 8 |
|
| 9 |
# --- Config from Env ---
|
| 10 |
API_URL = os.getenv("API_URL", "https://agents-course-unit4-scoring.hf.space")
|
| 11 |
-
SPACE_ID = os.getenv("SPACE_ID") # e.g. "user/your-space"
|
| 12 |
MODEL_ID = os.getenv("MODEL_ID", "meta-llama/Llama-2-7b-instruct")
|
| 13 |
-
# HF token: either from Secrets or from login profile
|
| 14 |
HF_TOKEN_ENV = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 15 |
|
| 16 |
-
if not SPACE_ID:
|
| 17 |
-
raise RuntimeError(
|
| 18 |
-
"❌ Please set SPACE_ID in your Space Secrets: e.g. user/your-space"
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
WELCOME = """
|
| 22 |
## GAIA Benchmark Runner 🎉
|
| 23 |
|
|
@@ -43,7 +36,6 @@ class GAIAAgent:
|
|
| 43 |
resp = requests.post(url, headers=self.headers, json=payload, timeout=60)
|
| 44 |
resp.raise_for_status()
|
| 45 |
data = resp.json()
|
| 46 |
-
# data is list of {"generated_text": "..."}
|
| 47 |
if isinstance(data, list) and data and "generated_text" in data[0]:
|
| 48 |
return data[0]["generated_text"].strip()
|
| 49 |
return str(data)
|
|
@@ -85,11 +77,10 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 85 |
payload.append({"task_id": tid, "submitted_answer": ans})
|
| 86 |
time.sleep(0.5)
|
| 87 |
|
| 88 |
-
# 4) Submit
|
| 89 |
submission = {
|
| 90 |
-
"username":
|
| 91 |
-
"
|
| 92 |
-
"answers": payload
|
| 93 |
}
|
| 94 |
s_resp = requests.post(f"{API_URL}/submit", json=submission, timeout=60)
|
| 95 |
s_resp.raise_for_status()
|
|
|
|
| 8 |
|
| 9 |
# --- Config from Env ---
|
| 10 |
API_URL = os.getenv("API_URL", "https://agents-course-unit4-scoring.hf.space")
|
|
|
|
| 11 |
MODEL_ID = os.getenv("MODEL_ID", "meta-llama/Llama-2-7b-instruct")
|
|
|
|
| 12 |
HF_TOKEN_ENV = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
WELCOME = """
|
| 15 |
## GAIA Benchmark Runner 🎉
|
| 16 |
|
|
|
|
| 36 |
resp = requests.post(url, headers=self.headers, json=payload, timeout=60)
|
| 37 |
resp.raise_for_status()
|
| 38 |
data = resp.json()
|
|
|
|
| 39 |
if isinstance(data, list) and data and "generated_text" in data[0]:
|
| 40 |
return data[0]["generated_text"].strip()
|
| 41 |
return str(data)
|
|
|
|
| 77 |
payload.append({"task_id": tid, "submitted_answer": ans})
|
| 78 |
time.sleep(0.5)
|
| 79 |
|
| 80 |
+
# 4) Submit (no agent_code)
|
| 81 |
submission = {
|
| 82 |
+
"username": username,
|
| 83 |
+
"answers": payload
|
|
|
|
| 84 |
}
|
| 85 |
s_resp = requests.post(f"{API_URL}/submit", json=submission, timeout=60)
|
| 86 |
s_resp.raise_for_status()
|