File size: 1,452 Bytes
3df5153
 
3d1b0c5
3df5153
 
d6ca7ae
 
3df5153
d2fa4ad
33cdb30
3d1b0c5
 
94b05f0
3df5153
d6ca7ae
3d1b0c5
 
 
 
3df5153
3d1b0c5
 
d2fa4ad
 
3d1b0c5
d2fa4ad
d6ca7ae
d2fa4ad
 
3d1b0c5
d6ca7ae
3d1b0c5
 
 
d2fa4ad
 
 
 
 
3d1b0c5
 
 
 
d2fa4ad
 
3d1b0c5
d6ca7ae
d2fa4ad
 
 
 
 
 
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
import gradio as gr
import json
import os
import requests

from .agent import solve_task, load_tasks
from .mistral_hf_wrapper import MistralInference

# Load from environment variables
API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
API_TOKEN = os.getenv("HF_TOKEN")
USERNAME = os.getenv("HF_USERNAME")
CODE_LINK = os.getenv("HF_CODE_LINK")

# Launches agent to solve all tasks and submits to GAIA
def run_and_submit_all():
    model = MistralInference(api_url=API_URL, api_token=API_TOKEN)
    tasks = load_tasks()
    answers = []

    for task in tasks:
        try:
            result = solve_task(task, model)
            answers.append(result)
        except Exception as e:
            answers.append({
                "task_id": task.get("question_id", "unknown"),
                "submitted_answer": f"ERROR: {str(e)}"
            })

    # Submit results to GAIA benchmark API
    res = requests.post(
        "https://agents-course-unit4-scoring.hf.space/submit",
        headers={"Content-Type": "application/json"},
        json={
            "username": USERNAME,
            "agent_code": CODE_LINK,
            "answers": answers
        },
    )

    if res.ok:
        return json.dumps(res.json(), indent=2)
    else:
        return f"Error submitting: {res.status_code} - {res.text}"

# Gradio interface
gr.Interface(
    fn=run_and_submit_all,
    inputs=[],
    outputs="textbox",
    title="GAIA Benchmark Agent Submission"
).launch()