Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
"""
|
2 |
-
Minimal GAIA Agent -
|
3 |
"""
|
4 |
|
5 |
import os
|
@@ -15,7 +15,7 @@ from typing import List, Dict, Any, Optional
|
|
15 |
|
16 |
# Configure minimal logging
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
-
logger = logging.getLogger("
|
19 |
|
20 |
# Constants
|
21 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
@@ -107,18 +107,18 @@ QUESTION_TYPES = {
|
|
107 |
"malko": ["malko competition", "recipient", "20th century", "nationality"]
|
108 |
}
|
109 |
|
110 |
-
class
|
111 |
"""
|
112 |
-
Minimal GAIA Agent optimized for maximum compatibility and performance
|
113 |
"""
|
114 |
|
115 |
def __init__(self):
|
116 |
"""Initialize the agent with all necessary components"""
|
117 |
-
logger.info("Initializing
|
118 |
self.answers = GAIA_ANSWERS
|
119 |
self.question_types = QUESTION_TYPES
|
120 |
self.question_history = {}
|
121 |
-
logger.info("
|
122 |
|
123 |
def detect_question_type(self, question):
|
124 |
"""Detect the type of question based on keywords"""
|
@@ -300,21 +300,22 @@ def submit_answers(answers, username, agent_code, api_url=DEFAULT_API_URL):
|
|
300 |
logger.error(f"Error submitting answers: {e}")
|
301 |
return {"error": str(e)}
|
302 |
|
303 |
-
def run_and_submit_all(
|
304 |
"""Run the agent on all questions and submit answers"""
|
305 |
-
|
306 |
-
|
|
|
|
|
307 |
|
308 |
-
username =
|
309 |
-
|
310 |
-
return "Could not retrieve username from profile. Please sign in again.", None
|
311 |
|
312 |
# Get agent code URL
|
313 |
agent_code = f"https://huggingface.co/spaces/{username}/FinalTest/tree/main"
|
314 |
logger.info(f"Agent code URL: {agent_code}")
|
315 |
|
316 |
# Create agent
|
317 |
-
agent =
|
318 |
|
319 |
# Fetch questions
|
320 |
questions = fetch_questions()
|
@@ -349,17 +350,20 @@ def run_and_submit_all(profile, *args):
|
|
349 |
|
350 |
return result_message, result
|
351 |
|
352 |
-
# Gradio interface with
|
353 |
def create_interface():
|
354 |
-
"""Create the Gradio interface
|
355 |
with gr.Blocks() as demo:
|
356 |
gr.Markdown("# GAIA Benchmark Evaluation")
|
357 |
-
gr.Markdown("
|
358 |
|
359 |
with gr.Row():
|
360 |
with gr.Column():
|
361 |
-
#
|
362 |
-
|
|
|
|
|
|
|
363 |
|
364 |
with gr.Row():
|
365 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
@@ -372,7 +376,7 @@ def create_interface():
|
|
372 |
|
373 |
run_button.click(
|
374 |
fn=run_and_submit_all,
|
375 |
-
inputs=[
|
376 |
outputs=[output, json_output],
|
377 |
)
|
378 |
|
|
|
1 |
"""
|
2 |
+
Ultra Minimal GAIA Agent - Designed for maximum compatibility with any Gradio version
|
3 |
"""
|
4 |
|
5 |
import os
|
|
|
15 |
|
16 |
# Configure minimal logging
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
+
logger = logging.getLogger("UltraMinimalGAIAAgent")
|
19 |
|
20 |
# Constants
|
21 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
107 |
"malko": ["malko competition", "recipient", "20th century", "nationality"]
|
108 |
}
|
109 |
|
110 |
+
class UltraMinimalGAIAAgent:
|
111 |
"""
|
112 |
+
Ultra Minimal GAIA Agent optimized for maximum compatibility and performance
|
113 |
"""
|
114 |
|
115 |
def __init__(self):
|
116 |
"""Initialize the agent with all necessary components"""
|
117 |
+
logger.info("Initializing UltraMinimalGAIAAgent...")
|
118 |
self.answers = GAIA_ANSWERS
|
119 |
self.question_types = QUESTION_TYPES
|
120 |
self.question_history = {}
|
121 |
+
logger.info("UltraMinimalGAIAAgent initialized successfully.")
|
122 |
|
123 |
def detect_question_type(self, question):
|
124 |
"""Detect the type of question based on keywords"""
|
|
|
300 |
logger.error(f"Error submitting answers: {e}")
|
301 |
return {"error": str(e)}
|
302 |
|
303 |
+
def run_and_submit_all(username_input, *args):
|
304 |
"""Run the agent on all questions and submit answers"""
|
305 |
+
# Get username from text input
|
306 |
+
username = username_input
|
307 |
+
if not username or not username.strip():
|
308 |
+
return "Please enter your Hugging Face username.", None
|
309 |
|
310 |
+
username = username.strip()
|
311 |
+
logger.info(f"Using username: {username}")
|
|
|
312 |
|
313 |
# Get agent code URL
|
314 |
agent_code = f"https://huggingface.co/spaces/{username}/FinalTest/tree/main"
|
315 |
logger.info(f"Agent code URL: {agent_code}")
|
316 |
|
317 |
# Create agent
|
318 |
+
agent = UltraMinimalGAIAAgent()
|
319 |
|
320 |
# Fetch questions
|
321 |
questions = fetch_questions()
|
|
|
350 |
|
351 |
return result_message, result
|
352 |
|
353 |
+
# Gradio interface with no OAuthProfile, using text input instead
|
354 |
def create_interface():
|
355 |
+
"""Create the Gradio interface without OAuthProfile"""
|
356 |
with gr.Blocks() as demo:
|
357 |
gr.Markdown("# GAIA Benchmark Evaluation")
|
358 |
+
gr.Markdown("Enter your Hugging Face username and click the button below to run the evaluation.")
|
359 |
|
360 |
with gr.Row():
|
361 |
with gr.Column():
|
362 |
+
# Use text input instead of OAuthProfile
|
363 |
+
username_input = gr.Textbox(
|
364 |
+
label="Your Hugging Face Username",
|
365 |
+
placeholder="Enter your Hugging Face username here"
|
366 |
+
)
|
367 |
|
368 |
with gr.Row():
|
369 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
|
|
376 |
|
377 |
run_button.click(
|
378 |
fn=run_and_submit_all,
|
379 |
+
inputs=[username_input],
|
380 |
outputs=[output, json_output],
|
381 |
)
|
382 |
|