m-ric HF Staff commited on
Commit
58a7eda
·
1 Parent(s): a767770

Tickbox for consent storage

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -526,20 +526,23 @@ class EnrichedGradioUI(GradioUI):
526
  stored_messages.append(msg)
527
  yield stored_messages
528
 
529
- # THIS ERASES IMAGES FROM MEMORY, USE WITH CAUTION
530
- summary = get_agent_summary_erase_images(session_state["agent"])
531
- save_final_status(data_dir, "completed", summary = summary)
 
532
  yield stored_messages
533
 
534
  except Exception as e:
535
  error_message=f"Error in interaction: {str(e)}"
536
  print(error_message)
537
  stored_messages.append(gr.ChatMessage(role="assistant", content="Run failed:\n" + error_message))
538
- summary = get_agent_summary_erase_images(session_state["agent"])
539
- save_final_status(data_dir, "failed", summary=summary, error_message=error_message)
 
540
  yield stored_messages
541
  finally:
542
- upload_to_hf_and_remove(data_dir)
 
543
 
544
  theme = gr.themes.Default(font=["Oxanium", "sans-serif"], primary_hue="amber", secondary_hue="blue")
545
 
@@ -565,8 +568,8 @@ In this app, you'll be able to interact with an agent powered by [smolagents](ht
565
 
566
  👉 Type a task in the left sidebar, click the button, and watch the agent solving your task. ✨
567
 
568
- _Please note that we store the tasks given to this agent. Do not type any confidential information!_
569
- _You can reach out at @hf.co to request deletion of information._
570
  """)
571
  task_input = gr.Textbox(
572
  value="Download a picture of a cute puppy from Google",
@@ -592,12 +595,15 @@ _You can reach out at @hf.co to request deletion of information._
592
  )
593
 
594
  session_state = gr.State({})
 
595
  stored_messages = gr.State([])
596
 
 
597
 
598
- # replay_btn = gr.Button("Replay an agent run")
 
599
 
600
- minimalist_toggle = gr.Checkbox(label="Innie/Outie", value=False)
601
 
602
  def apply_theme(minimalist_mode: bool):
603
  if not minimalist_mode:
 
526
  stored_messages.append(msg)
527
  yield stored_messages
528
 
529
+ # THIS ERASES IMAGES FROM AGENT MEMORY, USE WITH CAUTION
530
+ if session_state["consent_storage"]:
531
+ summary = get_agent_summary_erase_images(session_state["agent"])
532
+ save_final_status(data_dir, "completed", summary = summary)
533
  yield stored_messages
534
 
535
  except Exception as e:
536
  error_message=f"Error in interaction: {str(e)}"
537
  print(error_message)
538
  stored_messages.append(gr.ChatMessage(role="assistant", content="Run failed:\n" + error_message))
539
+ if session_state["consent_storage"]:
540
+ summary = get_agent_summary_erase_images(session_state["agent"])
541
+ save_final_status(data_dir, "failed", summary=summary, error_message=error_message)
542
  yield stored_messages
543
  finally:
544
+ if session_state["consent_storage"]:
545
+ upload_to_hf_and_remove(data_dir)
546
 
547
  theme = gr.themes.Default(font=["Oxanium", "sans-serif"], primary_hue="amber", secondary_hue="blue")
548
 
 
568
 
569
  👉 Type a task in the left sidebar, click the button, and watch the agent solving your task. ✨
570
 
571
+ _Please note that we store the tasks given to this agent. **Do not type any confidential information!**_
572
+ _If you do not consent to this collection, you can untick a box in the sidebar to disable task and trace storage._
573
  """)
574
  task_input = gr.Textbox(
575
  value="Download a picture of a cute puppy from Google",
 
595
  )
596
 
597
  session_state = gr.State({})
598
+ session_state["consent_storage"] = True
599
  stored_messages = gr.State([])
600
 
601
+ minimalist_toggle = gr.Checkbox(label="Innie/Outie", value=False)
602
 
603
+ def add_items(session_state):
604
+ session_state["consent_storage"] = not session_state["consent_storage"]
605
 
606
+ gr.Button("Store task and agent trace?").click(add_items, session_state)
607
 
608
  def apply_theme(minimalist_mode: bool):
609
  if not minimalist_mode: