helene-rousset commited on
Commit
3acdcf3
·
verified ·
1 Parent(s): e32e7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -11,7 +11,7 @@ import json
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
 
14
- def run_and_submit_all( profile: gr.OAuthProfile | None):
15
  """
16
  Fetches all questions, runs the BasicAgent on them, submits all answers,
17
  and displays the results.
@@ -138,6 +138,10 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
138
  return status_message, results_df
139
 
140
 
 
 
 
 
141
  # --- Build Gradio Interface using Blocks ---
142
  with gr.Blocks() as demo:
143
  gr.Markdown("# Basic Agent Evaluation Runner")
@@ -158,6 +162,8 @@ with gr.Blocks() as demo:
158
 
159
  gr.LoginButton()
160
 
 
 
161
  run_button = gr.Button("Run Evaluation & Submit All Answers")
162
 
163
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
@@ -169,6 +175,11 @@ with gr.Blocks() as demo:
169
  outputs=[status_output, results_table]
170
  )
171
 
 
 
 
 
 
172
  if __name__ == "__main__":
173
  print("\n" + "-"*30 + " App Starting " + "-"*30)
174
  # Check for SPACE_HOST and SPACE_ID at startup for information
 
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
 
14
+ def run_and_submit_all(profile: gr.OAuthProfile | None):
15
  """
16
  Fetches all questions, runs the BasicAgent on them, submits all answers,
17
  and displays the results.
 
138
  return status_message, results_df
139
 
140
 
141
+ def save_fn(profile: gr.OAuthProfile | None):
142
+ with open("saved_answers.json", "w") as f:
143
+ json.dump([], f, indent=2)
144
+
145
  # --- Build Gradio Interface using Blocks ---
146
  with gr.Blocks() as demo:
147
  gr.Markdown("# Basic Agent Evaluation Runner")
 
162
 
163
  gr.LoginButton()
164
 
165
+ save_button = gr.Button("Save JSON")
166
+
167
  run_button = gr.Button("Run Evaluation & Submit All Answers")
168
 
169
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
 
175
  outputs=[status_output, results_table]
176
  )
177
 
178
+ save_button.click(
179
+ fn=save_fn
180
+ )
181
+
182
+
183
  if __name__ == "__main__":
184
  print("\n" + "-"*30 + " App Starting " + "-"*30)
185
  # Check for SPACE_HOST and SPACE_ID at startup for information