sanjaystarc commited on
Commit
12232f8
·
verified ·
1 Parent(s): 09483c8

upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +11 -12
  2. app.py +96 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,12 +1,11 @@
1
- ---
2
- title: Starc Agent
3
- emoji: 😻
4
- colorFrom: purple
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.49.1
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # 🤗 GAIA Agent Submission
2
+
3
+ This is my Hugging Face Space for the GAIA Leaderboard Assignment.
4
+
5
+ It:
6
+ - Fetches evaluation questions from the GAIA API
7
+ - Generates simple answers
8
+ - Submits them to the leaderboard
9
+
10
+ ### Replace Logic
11
+ Modify `answer_question()` in `app.py` to use your own reasoning or LLM for better accuracy.
 
app.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+ import os
4
+
5
+ # ====================================================
6
+ # CONFIGURATION
7
+ # ====================================================
8
+ BASE_URL = "https://huggingface.co/api/gaia" # Replace with your actual GAIA API base URL
9
+ USERNAME = os.getenv("HF_USERNAME") or "your_hf_username_here"
10
+ AGENT_CODE = "https://huggingface.co/spaces/your_username/gaia-agent/tree/main"
11
+
12
+
13
+ # ====================================================
14
+ # API FUNCTIONS
15
+ # ====================================================
16
+ def get_questions():
17
+ """Retrieve all evaluation questions"""
18
+ resp = requests.get(f"{BASE_URL}/questions")
19
+ resp.raise_for_status()
20
+ return resp.json()
21
+
22
+
23
+ def get_random_question():
24
+ """Retrieve a random single question"""
25
+ resp = requests.get(f"{BASE_URL}/random-question")
26
+ resp.raise_for_status()
27
+ return resp.json()
28
+
29
+
30
+ def submit_answers(answers):
31
+ """Submit all answers to the leaderboard"""
32
+ payload = {
33
+ "username": USERNAME,
34
+ "agent_code": AGENT_CODE,
35
+ "answers": answers
36
+ }
37
+ resp = requests.post(f"{BASE_URL}/submit", json=payload)
38
+ resp.raise_for_status()
39
+ return resp.json()
40
+
41
+
42
+ # ====================================================
43
+ # AGENT LOGIC
44
+ # ====================================================
45
+ def answer_question(question):
46
+ """Simple rule-based answering agent (replace with LLM logic later)"""
47
+ q_text = question["question_text"].lower()
48
+
49
+ if "capital" in q_text:
50
+ return "Paris"
51
+ elif "language" in q_text:
52
+ return "English"
53
+ elif "2+2" in q_text or "two plus two" in q_text:
54
+ return "4"
55
+ else:
56
+ return "Unknown"
57
+
58
+
59
+ def run_agent():
60
+ """Fetch all questions and generate answers"""
61
+ questions = get_questions()
62
+ answers = []
63
+ for q in questions:
64
+ ans = answer_question(q)
65
+ answers.append({
66
+ "task_id": q["task_id"],
67
+ "submitted_answer": ans
68
+ })
69
+ return answers
70
+
71
+
72
+ # ====================================================
73
+ # GRADIO UI
74
+ # ====================================================
75
+ def main_ui():
76
+ def on_run():
77
+ answers = run_agent()
78
+ result = submit_answers(answers)
79
+ return f"✅ Submission complete!\n\nResult:\n{result}"
80
+
81
+ iface = gr.Interface(
82
+ fn=on_run,
83
+ inputs=[],
84
+ outputs="text",
85
+ title="🤗 GAIA Agent Submission Tool",
86
+ description=(
87
+ "This tool fetches GAIA questions, generates simple answers, and submits them "
88
+ "to the Hugging Face leaderboard.\n\n"
89
+ "👉 Replace the `answer_question()` logic with your own model or reasoning approach."
90
+ )
91
+ )
92
+ iface.launch()
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main_ui()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ requests
3
+ transformers
4
+ torch