Spaces:
Runtime error
Runtime error
Refactor BasicAgent into a dedicated module
Browse filesExtracted the BasicAgent class into a new `agent.py` module under `gaia_solving_agent` for better modularity and maintainability.
- .gitignore +2 -1
- app.py +0 -17
- src/gaia_solving_agent/__init__ +0 -0
- src/gaia_solving_agent/agent.py +8 -0
- src/gaia_solving_agent/hf_submission_api.py +4 -1
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
.idea/*
|
|
|
|
|
|
| 1 |
+
.idea/*
|
| 2 |
+
*.egg-info
|
app.py
CHANGED
|
@@ -4,23 +4,6 @@ import gradio as gr
|
|
| 4 |
from gaia_solving_agent.hf_submission_api import instantiate_agent, fetching_questions, run_agent, \
|
| 5 |
prepare_submission_data, submit_answers
|
| 6 |
|
| 7 |
-
# (Keep Constants as is)
|
| 8 |
-
# --- Constants ---
|
| 9 |
-
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
# --- Basic Agent Definition ---
|
| 13 |
-
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
-
class BasicAgent:
|
| 15 |
-
def __init__(self):
|
| 16 |
-
print("BasicAgent initialized.")
|
| 17 |
-
def __call__(self, question: str) -> str:
|
| 18 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 19 |
-
fixed_answer = "This is a default answer."
|
| 20 |
-
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 21 |
-
return fixed_answer
|
| 22 |
-
|
| 23 |
-
|
| 24 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 25 |
"""
|
| 26 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 4 |
from gaia_solving_agent.hf_submission_api import instantiate_agent, fetching_questions, run_agent, \
|
| 5 |
prepare_submission_data, submit_answers
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 8 |
"""
|
| 9 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
src/gaia_solving_agent/__init__
ADDED
|
File without changes
|
src/gaia_solving_agent/agent.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class BasicAgent:
|
| 2 |
+
def __init__(self):
|
| 3 |
+
print("BasicAgent initialized.")
|
| 4 |
+
def __call__(self, question: str) -> str:
|
| 5 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 6 |
+
fixed_answer = "This is a default answer."
|
| 7 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 8 |
+
return fixed_answer
|
src/gaia_solving_agent/hf_submission_api.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
from
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def instantiate_agent(space_id: str):
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
from gaia_solving_agent.agent import BasicAgent
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 8 |
|
| 9 |
|
| 10 |
def instantiate_agent(space_id: str):
|