Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import time | |
| import requests | |
| GAIA_API = "https://gaia-benchmark-api.com" # Only for submission, not fetching questions here | |
| # Static list of benchmark questions | |
| def get_questions(): | |
| return [ | |
| {"task_id": "1", "question": "What is artificial intelligence?"}, | |
| {"task_id": "2", "question": "Explain supervised learning."}, | |
| {"task_id": "3", "question": "What is a neural network?"}, | |
| {"task_id": "4", "question": "What is reinforcement learning?"}, | |
| {"task_id": "5", "question": "Define overfitting in machine learning."}, | |
| ] | |
| # Correct answers mapped to task IDs | |
| correct_answers = { | |
| "1": "Artificial intelligence is the simulation of human intelligence in machines that are programmed to think and learn.", | |
| "2": "Supervised learning is a type of machine learning where the model is trained on labeled data.", | |
| "3": "A neural network is a series of algorithms that mimic the operations of a human brain to recognize relationships in data.", | |
| "4": "Reinforcement learning is a type of machine learning where an agent learns to make decisions by receiving rewards or penalties.", | |
| "5": "Overfitting occurs when a model learns the training data too well including noise, resulting in poor generalization to new data." | |
| } | |
| def answer_all(): | |
| questions = get_questions() | |
| answers = [] | |
| for q in questions: | |
| task_id = q["task_id"] | |
| answer = correct_answers.get(task_id, "No answer available.") | |
| answers.append({ | |
| "task_id": task_id, | |
| "submitted_answer": answer | |
| }) | |
| time.sleep(0.5) # slight delay to simulate processing | |
| return answers, None | |
| def submit_to_leaderboard(username, code_link): | |
| results, error = answer_all() | |
| if error: | |
| return error | |
| payload = { | |
| "username": username, | |
| "agent_code": code_link, | |
| "answers": results | |
| } | |
| try: | |
| res = requests.post(f"{GAIA_API}/submit", json=payload) | |
| if res.status_code == 200: | |
| return f"β Submission Successful!\n\n{res.json()}" | |
| else: | |
| return f"β Submission Failed: {res.status_code}\n{res.text}" | |
| except Exception as e: | |
| return f"β Error during submission: {e}" | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## π€ GAIA Agent Submission Portal\nSubmit your answers and join the leaderboard!") | |
| username = gr.Textbox(label="πΉ HuggingFace Username", placeholder="e.g. PavanKumarGurram") | |
| code_url = gr.Textbox(label="π Public Link to Your Space (code view)", placeholder="e.g. https://huggingface.co/spaces/PavanKumarGurram/gaia-agent-pavan/tree/main") | |
| submit_btn = gr.Button("π Submit My Agent") | |
| output = gr.Textbox(label="π’ Submission Result", lines=10) | |
| submit_btn.click(fn=submit_to_leaderboard, inputs=[username, code_url], outputs=output) | |
| if __name__ == "__main__": | |
| demo.launch() | |