bstraehle commited on
Commit
057f972
·
verified ·
1 Parent(s): c3efb0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -2,17 +2,16 @@
2
 
3
  # https://www.gradio.app/guides/quickstart
4
 
5
- import gradio.utils, os
6
  import gradio as gr
7
  from agents.crew import run_crew
 
 
8
  from utils.utils import (
9
  DATASET_TYPE_GAIA,
10
  DATASET_TYPE_HLE,
11
  get_dataset
12
  )
13
- import sys
14
- from io import StringIO
15
- from contextlib import contextmanager
16
 
17
  # Configuration
18
 
@@ -24,9 +23,9 @@ BASE_URL = f"https://huggingface.co/spaces/{SPACE_ID}/blob/main"
24
 
25
  @contextmanager
26
  def capture_output():
27
- """Context manager to capture stdout and stderr"""
28
  old_stdout = sys.stdout
29
  old_stderr = sys.stderr
 
30
  try:
31
  sys.stdout = StringIO()
32
  sys.stderr = StringIO()
@@ -81,14 +80,12 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
81
  os.environ["GEMINI_API_KEY"] = gemini_key
82
  os.environ["ANTHROPIC_API_KEY"] = anthropic_key
83
 
84
- # Capture console output
85
  with capture_output() as (stdout, stderr):
86
  answer = run_crew(question, file_name)
87
 
88
- # Get captured logs
89
  stdout_logs = stdout.getvalue()
90
  stderr_logs = stderr.getvalue()
91
- console_logs = stdout_logs + ("\n" + stderr_logs if stderr_logs else "")
92
 
93
  return answer, console_logs
94
  except Exception as e:
@@ -117,9 +114,9 @@ DESCRIPTION = (
117
  f"The system can solve multiple <a href='https://arxiv.org/pdf/2311.12983'>GAIA Benchmark</a> "
118
  f"Level 1, 2, 3 and even <a href='https://arxiv.org/pdf/2501.14249'>Humanity's Last Exam</a> "
119
  f"problems. To get started, select from the examples below. "
120
- f"Processing can take several minutes depending on the question complexity. "
121
- f"Console logs are provided belowfor transparency.</p>"
122
- f"API keys are provided thanks to sponsor credit. "
123
  f"<a href='{BASE_URL}/README.md'>Documentation</a></p>"
124
  )
125
 
@@ -220,17 +217,15 @@ with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
220
  lines=1,
221
  max_lines=1
222
  )
223
-
224
- # Console logs section
225
- with gr.Accordion("Console Logs & Tool Calls", open=False):
226
  console_logs = gr.Textbox(
227
- label="Console Output",
228
  interactive=False,
229
  lines=25,
230
  max_lines=25
231
  )
232
 
233
- # Clear button (after all components are defined)
234
  with gr.Row():
235
  clear_btn = gr.ClearButton(
236
  components=[question, ground_truth, file_name, file_link, answer, console_logs]
@@ -253,7 +248,7 @@ with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
253
  gr.Examples(
254
  examples=get_dataset(DATASET_TYPE_GAIA, 1),
255
  inputs=[question, ground_truth, file_name, "", "", ""],
256
- examples_per_page=3,
257
  cache_examples=False
258
  )
259
 
@@ -261,7 +256,7 @@ with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
261
  gr.Examples(
262
  examples=get_dataset(DATASET_TYPE_GAIA, 2),
263
  inputs=[question, ground_truth, file_name, "", "", ""],
264
- examples_per_page=3,
265
  cache_examples=False
266
  )
267
 
@@ -269,7 +264,7 @@ with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
269
  gr.Examples(
270
  examples=get_dataset(DATASET_TYPE_GAIA, 3),
271
  inputs=[question, ground_truth, file_name, "", "", ""],
272
- examples_per_page=3,
273
  cache_examples=False
274
  )
275
 
@@ -277,7 +272,7 @@ with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
277
  gr.Examples(
278
  examples=get_dataset(DATASET_TYPE_HLE, 0),
279
  inputs=[question, ground_truth, file_name, "", "", ""],
280
- examples_per_page=3,
281
  cache_examples=False
282
  )
283
 
 
2
 
3
  # https://www.gradio.app/guides/quickstart
4
 
5
+ import gradio.utils, os, sys
6
  import gradio as gr
7
  from agents.crew import run_crew
8
+ from contextlib import contextmanager
9
+ from io import StringIO
10
  from utils.utils import (
11
  DATASET_TYPE_GAIA,
12
  DATASET_TYPE_HLE,
13
  get_dataset
14
  )
 
 
 
15
 
16
  # Configuration
17
 
 
23
 
24
  @contextmanager
25
  def capture_output():
 
26
  old_stdout = sys.stdout
27
  old_stderr = sys.stderr
28
+
29
  try:
30
  sys.stdout = StringIO()
31
  sys.stderr = StringIO()
 
80
  os.environ["GEMINI_API_KEY"] = gemini_key
81
  os.environ["ANTHROPIC_API_KEY"] = anthropic_key
82
 
 
83
  with capture_output() as (stdout, stderr):
84
  answer = run_crew(question, file_name)
85
 
 
86
  stdout_logs = stdout.getvalue()
87
  stderr_logs = stderr.getvalue()
88
+ console_logs = stdout_logs + (stderr_logs if stderr_logs else "")
89
 
90
  return answer, console_logs
91
  except Exception as e:
 
114
  f"The system can solve multiple <a href='https://arxiv.org/pdf/2311.12983'>GAIA Benchmark</a> "
115
  f"Level 1, 2, 3 and even <a href='https://arxiv.org/pdf/2501.14249'>Humanity's Last Exam</a> "
116
  f"problems. To get started, select from the examples below. "
117
+ f"Processing can take minutes depending on question complexity. "
118
+ f"Console logs are provided below for transparency. "
119
+ f"API keys are provided temporarily thanks to sponsor credit. "
120
  f"<a href='{BASE_URL}/README.md'>Documentation</a></p>"
121
  )
122
 
 
217
  lines=1,
218
  max_lines=1
219
  )
220
+
221
+ with gr.Accordion("Console Logs", open=False):
 
222
  console_logs = gr.Textbox(
223
+ label="Output",
224
  interactive=False,
225
  lines=25,
226
  max_lines=25
227
  )
228
 
 
229
  with gr.Row():
230
  clear_btn = gr.ClearButton(
231
  components=[question, ground_truth, file_name, file_link, answer, console_logs]
 
248
  gr.Examples(
249
  examples=get_dataset(DATASET_TYPE_GAIA, 1),
250
  inputs=[question, ground_truth, file_name, "", "", ""],
251
+ examples_per_page=5,
252
  cache_examples=False
253
  )
254
 
 
256
  gr.Examples(
257
  examples=get_dataset(DATASET_TYPE_GAIA, 2),
258
  inputs=[question, ground_truth, file_name, "", "", ""],
259
+ examples_per_page=5,
260
  cache_examples=False
261
  )
262
 
 
264
  gr.Examples(
265
  examples=get_dataset(DATASET_TYPE_GAIA, 3),
266
  inputs=[question, ground_truth, file_name, "", "", ""],
267
+ examples_per_page=5,
268
  cache_examples=False
269
  )
270
 
 
272
  gr.Examples(
273
  examples=get_dataset(DATASET_TYPE_HLE, 0),
274
  inputs=[question, ground_truth, file_name, "", "", ""],
275
+ examples_per_page=5,
276
  cache_examples=False
277
  )
278