shrutikaP8497 commited on
Commit
996d1a7
·
verified ·
1 Parent(s): 89a4420

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -50
app.py CHANGED
@@ -1,50 +1,50 @@
1
- import gradio as gr
2
- import requests
3
- import os
4
- from agent import run_agent
5
- from utils import get_hf_username, get_code_link
6
-
7
- API_BASE = "https://agents-course-unit4-scoring.hf.space"
8
-
9
- def fetch_questions():
10
- response = requests.get(f"{API_BASE}/questions")
11
- if response.status_code == 200:
12
- return response.json()
13
- else:
14
- return []
15
-
16
- def submit_answers(answers, username, code_link):
17
- payload = {
18
- "username": username,
19
- "agent_code": code_link,
20
- "answers": answers
21
- }
22
- response = requests.post(f"{API_BASE}/submit", json=payload)
23
- if response.status_code == 200:
24
- return response.json()
25
- else:
26
- return {"message": "Submission failed.", "score": 0}
27
-
28
- def run_and_submit():
29
- questions = fetch_questions()
30
- answers = []
31
- for q in questions:
32
- answer = run_agent(q) # Your custom logic from agent.py
33
- answers.append({
34
- "task_id": q["task_id"],
35
- "submitted_answer": answer
36
- })
37
-
38
- username = get_hf_username()
39
- code_link = get_code_link()
40
- result = submit_answers(answers, username, code_link)
41
- return f"Score: {result.get('score', 0)}\nMessage: {result.get('message', 'No message')}"
42
-
43
- with gr.Blocks() as demo:
44
- gr.Markdown("## GAIA Agent Evaluation Space")
45
- with gr.Row():
46
- submit_btn = gr.Button("Run Evaluation & Submit All Answers")
47
- output = gr.Textbox(label="Submission Result")
48
- submit_btn.click(fn=run_and_submit, outputs=output)
49
-
50
- demo.launch()
 
1
+ import gradio as gr
2
+ import requests
3
+ import os
4
+ from agent import run_agent_on_question
5
+ from utils import get_hf_username, get_code_link
6
+
7
+ API_BASE = "https://agents-course-unit4-scoring.hf.space"
8
+
9
+ def fetch_questions():
10
+ response = requests.get(f"{API_BASE}/questions")
11
+ if response.status_code == 200:
12
+ return response.json()
13
+ else:
14
+ return []
15
+
16
+ def submit_answers(answers, username, code_link):
17
+ payload = {
18
+ "username": username,
19
+ "agent_code": code_link,
20
+ "answers": answers
21
+ }
22
+ response = requests.post(f"{API_BASE}/submit", json=payload)
23
+ if response.status_code == 200:
24
+ return response.json()
25
+ else:
26
+ return {"message": "Submission failed.", "score": 0}
27
+
28
+ def run_and_submit():
29
+ questions = fetch_questions()
30
+ answers = []
31
+ for q in questions:
32
+ answer = run_agent_on_question(q) # Your custom logic from agent.py
33
+ answers.append({
34
+ "task_id": q["task_id"],
35
+ "submitted_answer": answer
36
+ })
37
+
38
+ username = get_hf_username()
39
+ code_link = get_code_link()
40
+ result = submit_answers(answers, username, code_link)
41
+ return f"Score: {result.get('score', 0)}\nMessage: {result.get('message', 'No message')}"
42
+
43
+ with gr.Blocks() as demo:
44
+ gr.Markdown("## GAIA Agent Evaluation Space")
45
+ with gr.Row():
46
+ submit_btn = gr.Button("Run Evaluation & Submit All Answers")
47
+ output = gr.Textbox(label="Submission Result")
48
+ submit_btn.click(fn=run_and_submit, outputs=output)
49
+
50
+ demo.launch()