File size: 2,912 Bytes
71e1353
bc0ed15
f80b1ba
71e1353
f80b1ba
71e1353
f80b1ba
71e1353
f80b1ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71e1353
 
 
 
 
f80b1ba
 
bc0ed15
 
f80b1ba
bc0ed15
f80b1ba
bc0ed15
71e1353
 
bc0ed15
 
 
 
be87e9f
 
 
 
 
 
 
 
 
 
 
 
 
 
71e1353
 
f80b1ba
bc0ed15
 
be87e9f
bc0ed15
71e1353
bc0ed15
71e1353
fa4fc05
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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()