M-Rique commited on
Commit
1744fb6
·
1 Parent(s): 9d68600

Fix consent_storage

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -264,7 +264,7 @@ class EnrichedGradioUI(GradioUI):
264
  data_dir = os.path.join(TMP_DIR, interaction_id)
265
  print("CREATING DATA DIR", data_dir, "FROM", TMP_DIR, interaction_id)
266
 
267
- if not os.path.exists(data_dir):
268
  os.makedirs(data_dir)
269
 
270
  # Always re-create an agent from scratch, else Qwen-VL gets confused with past history
@@ -281,12 +281,13 @@ class EnrichedGradioUI(GradioUI):
281
  )
282
  yield stored_messages
283
 
284
- with open(os.path.join(data_dir, "metadata.jsonl"), "w") as output_file:
285
- output_file.write(
286
- json.dumps(
287
- {"task": task_input},
 
 
288
  )
289
- )
290
 
291
  screenshot_bytes = session_state["agent"].desktop.screenshot(format="bytes")
292
  initial_screenshot = Image.open(BytesIO(screenshot_bytes))
@@ -345,11 +346,12 @@ class EnrichedGradioUI(GradioUI):
345
  status = "failed"
346
  yield stored_messages
347
  finally:
348
- summary = get_agent_summary_erase_images(session_state["agent"])
349
- save_final_status(
350
- data_dir, status, summary=summary, error_message=error_message
351
- )
352
- print("SAVING FINAL STATUS", data_dir, status, summary, error_message)
 
353
 
354
 
355
  theme = gr.themes.Default(
 
264
  data_dir = os.path.join(TMP_DIR, interaction_id)
265
  print("CREATING DATA DIR", data_dir, "FROM", TMP_DIR, interaction_id)
266
 
267
+ if not os.path.exists(data_dir) and consent_storage:
268
  os.makedirs(data_dir)
269
 
270
  # Always re-create an agent from scratch, else Qwen-VL gets confused with past history
 
281
  )
282
  yield stored_messages
283
 
284
+ if consent_storage:
285
+ with open(os.path.join(data_dir, "metadata.jsonl"), "w") as output_file:
286
+ output_file.write(
287
+ json.dumps(
288
+ {"task": task_input},
289
+ )
290
  )
 
291
 
292
  screenshot_bytes = session_state["agent"].desktop.screenshot(format="bytes")
293
  initial_screenshot = Image.open(BytesIO(screenshot_bytes))
 
346
  status = "failed"
347
  yield stored_messages
348
  finally:
349
+ if consent_storage:
350
+ summary = get_agent_summary_erase_images(session_state["agent"])
351
+ save_final_status(
352
+ data_dir, status, summary=summary, error_message=error_message
353
+ )
354
+ print("SAVING FINAL STATUS", data_dir, status, summary, error_message)
355
 
356
 
357
  theme = gr.themes.Default(