Update app.py
Browse files
app.py
CHANGED
@@ -8,16 +8,40 @@ import pandas as pd
|
|
8 |
# --- Constants ---
|
9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
10 |
|
|
|
|
|
|
|
11 |
# --- Basic Agent Definition ---
|
12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
|
|
8 |
# --- Constants ---
|
9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
10 |
|
11 |
+
# Import your custom agent from agent.py
|
12 |
+
from agent import EnhancedGAIAAgent
|
13 |
+
|
14 |
# --- Basic Agent Definition ---
|
15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
16 |
class BasicAgent:
|
17 |
def __init__(self):
|
18 |
print("BasicAgent initialized.")
|
19 |
+
# Initialize your enhanced GAIA agent
|
20 |
+
self.gaia_agent = EnhancedGAIAAgent()
|
21 |
+
|
22 |
def __call__(self, question: str) -> str:
|
23 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
24 |
+
|
25 |
+
# Use your GAIA agent instead of fixed answer
|
26 |
+
try:
|
27 |
+
# Create question data structure expected by your GAIA agent
|
28 |
+
question_data = {
|
29 |
+
"Question": question,
|
30 |
+
"task_id": "basic_agent_task"
|
31 |
+
}
|
32 |
+
|
33 |
+
# Call your GAIA agent's solve method
|
34 |
+
import asyncio
|
35 |
+
answer = asyncio.run(self.gaia_agent.solve_gaia_question(question_data))
|
36 |
+
|
37 |
+
print(f"Agent returning GAIA answer: {answer[:100]}...")
|
38 |
+
return answer
|
39 |
+
|
40 |
+
except Exception as e:
|
41 |
+
print(f"Error using GAIA agent: {str(e)}")
|
42 |
+
fixed_answer = "This is a default answer."
|
43 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
44 |
+
return fixed_answer
|
45 |
|
46 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
47 |
"""
|