SantoshKumar1310 commited on
Commit
f4522ca
·
verified ·
1 Parent(s): 5c3f940

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import requests
4
  import pandas as pd
5
  from typing import Dict, List
 
6
 
7
  # custom imports
8
  from agents import Agent
@@ -11,7 +12,8 @@ from model import get_model
11
 
12
  # --- Constants ---
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
- MODEL_ID = "gemini/gemini-2.0-flash-exp"
 
15
 
16
 
17
  # --- Async Question Processing ---
@@ -31,13 +33,18 @@ async def process_question(agent, question: str, task_id: str) -> Dict:
31
  }
32
 
33
  async def run_questions_async(agent, questions_data: List[Dict]) -> tuple:
34
- """Process questions sequentially"""
35
  submissions = []
36
  logs = []
37
 
38
  total = len(questions_data)
39
  for idx, q in enumerate(questions_data):
40
  print(f"Processing {idx+1}/{total}: {q['question'][:80]}...")
 
 
 
 
 
41
  result = await process_question(agent, q["question"], q["task_id"])
42
  submissions.append(result["submission"])
43
  logs.append(result["log"])
@@ -86,7 +93,8 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
86
  print("Fetched questions list is empty.")
87
  return "Fetched questions list is empty or invalid format.", None
88
  print(f"Fetched {len(questions_data)} questions.")
89
- # Remove this line to process all questions: questions_data = questions_data[:2]
 
90
  except Exception as e:
91
  print(f"Error fetching questions: {e}")
92
  return f"Error fetching questions: {e}", None
@@ -134,15 +142,18 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
134
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
135
  gr.Markdown("# 🤖 GAIA Agent Evaluation")
136
  gr.Markdown(
137
- """
138
  **Instructions:**
139
  1. Log in to your Hugging Face account using the button below
140
  2. Click 'Run Evaluation & Submit' to test your agent
141
  3. The agent will use web search and other tools to answer questions
142
 
143
  **Current Setup:**
144
- - Model: Gemini 2.0 Flash (via LiteLLM)
145
  - Tools: Web search, Wikipedia, calculation, and more
 
 
 
146
  """
147
  )
148
 
@@ -162,6 +173,7 @@ if __name__ == "__main__":
162
  print("\n" + "="*70)
163
  print("🤖 GAIA Agent Starting")
164
  print("="*70)
 
165
 
166
  space_host = os.getenv("SPACE_HOST")
167
  space_id = os.getenv("SPACE_ID")
 
3
  import requests
4
  import pandas as pd
5
  from typing import Dict, List
6
+ import asyncio
7
 
8
  # custom imports
9
  from agents import Agent
 
12
 
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
15
+ MODEL_ID = "groq/llama-3.3-70b-versatile" # Groq's fastest model
16
+ RATE_LIMIT_DELAY = 1 # Groq has generous rate limits
17
 
18
 
19
  # --- Async Question Processing ---
 
33
  }
34
 
35
  async def run_questions_async(agent, questions_data: List[Dict]) -> tuple:
36
+ """Process questions sequentially with minimal rate limiting"""
37
  submissions = []
38
  logs = []
39
 
40
  total = len(questions_data)
41
  for idx, q in enumerate(questions_data):
42
  print(f"Processing {idx+1}/{total}: {q['question'][:80]}...")
43
+
44
+ # Add small delay between requests
45
+ if idx > 0:
46
+ await asyncio.sleep(RATE_LIMIT_DELAY)
47
+
48
  result = await process_question(agent, q["question"], q["task_id"])
49
  submissions.append(result["submission"])
50
  logs.append(result["log"])
 
93
  print("Fetched questions list is empty.")
94
  return "Fetched questions list is empty or invalid format.", None
95
  print(f"Fetched {len(questions_data)} questions.")
96
+ estimated_time = len(questions_data) * RATE_LIMIT_DELAY / 60
97
+ print(f"⏱️ Estimated time: {estimated_time:.1f} minutes")
98
  except Exception as e:
99
  print(f"Error fetching questions: {e}")
100
  return f"Error fetching questions: {e}", None
 
142
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
143
  gr.Markdown("# 🤖 GAIA Agent Evaluation")
144
  gr.Markdown(
145
+ f"""
146
  **Instructions:**
147
  1. Log in to your Hugging Face account using the button below
148
  2. Click 'Run Evaluation & Submit' to test your agent
149
  3. The agent will use web search and other tools to answer questions
150
 
151
  **Current Setup:**
152
+ - Model: Llama 3.3 70B (via Groq)
153
  - Tools: Web search, Wikipedia, calculation, and more
154
+ - Rate Limiting: {RATE_LIMIT_DELAY}s between requests
155
+
156
+ ⚠️ **Note:** Make sure you have set your GROQ_API_KEY in the Space secrets.
157
  """
158
  )
159
 
 
173
  print("\n" + "="*70)
174
  print("🤖 GAIA Agent Starting")
175
  print("="*70)
176
+ print(f"📝 Using Model: {MODEL_ID}")
177
 
178
  space_host = os.getenv("SPACE_HOST")
179
  space_id = os.getenv("SPACE_ID")