Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,9 @@ import gradio as gr
|
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
import requests
|
| 5 |
-
from .metadata import load_metadata
|
| 6 |
|
| 7 |
-
from agent import solve_task, load_tasks
|
| 8 |
-
from mistral_hf_wrapper import MistralInference
|
| 9 |
|
| 10 |
# Load from environment variables
|
| 11 |
API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
|
|
@@ -13,6 +12,7 @@ API_TOKEN = os.getenv("HF_TOKEN")
|
|
| 13 |
USERNAME = os.getenv("HF_USERNAME")
|
| 14 |
CODE_LINK = os.getenv("HF_CODE_LINK")
|
| 15 |
|
|
|
|
| 16 |
def run_and_submit_all():
|
| 17 |
model = MistralInference(api_url=API_URL, api_token=API_TOKEN)
|
| 18 |
tasks = load_tasks()
|
|
@@ -24,11 +24,11 @@ def run_and_submit_all():
|
|
| 24 |
answers.append(result)
|
| 25 |
except Exception as e:
|
| 26 |
answers.append({
|
| 27 |
-
"task_id": task
|
| 28 |
"submitted_answer": f"ERROR: {str(e)}"
|
| 29 |
})
|
| 30 |
|
| 31 |
-
# Submit
|
| 32 |
res = requests.post(
|
| 33 |
"https://agents-course-unit4-scoring.hf.space/submit",
|
| 34 |
headers={"Content-Type": "application/json"},
|
|
@@ -44,7 +44,7 @@ def run_and_submit_all():
|
|
| 44 |
else:
|
| 45 |
return f"Error submitting: {res.status_code} - {res.text}"
|
| 46 |
|
| 47 |
-
#
|
| 48 |
gr.Interface(
|
| 49 |
fn=run_and_submit_all,
|
| 50 |
inputs=[],
|
|
|
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
import requests
|
|
|
|
| 5 |
|
| 6 |
+
from .agent import solve_task, load_tasks
|
| 7 |
+
from .mistral_hf_wrapper import MistralInference
|
| 8 |
|
| 9 |
# Load from environment variables
|
| 10 |
API_URL = os.getenv("HF_MISTRAL_ENDPOINT")
|
|
|
|
| 12 |
USERNAME = os.getenv("HF_USERNAME")
|
| 13 |
CODE_LINK = os.getenv("HF_CODE_LINK")
|
| 14 |
|
| 15 |
+
# Launches agent to solve all tasks and submits to GAIA
|
| 16 |
def run_and_submit_all():
|
| 17 |
model = MistralInference(api_url=API_URL, api_token=API_TOKEN)
|
| 18 |
tasks = load_tasks()
|
|
|
|
| 24 |
answers.append(result)
|
| 25 |
except Exception as e:
|
| 26 |
answers.append({
|
| 27 |
+
"task_id": task.get("question_id", "unknown"),
|
| 28 |
"submitted_answer": f"ERROR: {str(e)}"
|
| 29 |
})
|
| 30 |
|
| 31 |
+
# Submit results to GAIA benchmark API
|
| 32 |
res = requests.post(
|
| 33 |
"https://agents-course-unit4-scoring.hf.space/submit",
|
| 34 |
headers={"Content-Type": "application/json"},
|
|
|
|
| 44 |
else:
|
| 45 |
return f"Error submitting: {res.status_code} - {res.text}"
|
| 46 |
|
| 47 |
+
# Gradio interface
|
| 48 |
gr.Interface(
|
| 49 |
fn=run_and_submit_all,
|
| 50 |
inputs=[],
|