daqc commited on
Commit
d8ea820
Β·
verified Β·
1 Parent(s): 9ec6c08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -33
app.py CHANGED
@@ -330,24 +330,7 @@ def clear_agent_only(session_id: str):
330
  del user_sessions[session_id]["agent"]
331
  logger.info(f"Session {session_id[:8]}... agent cleared")
332
 
333
- def cleanup_old_sessions():
334
- """Clean up sessions older than 1 hour."""
335
- with session_lock:
336
- current_time = datetime.now()
337
- sessions_to_remove = []
338
-
339
- for session_id, session_data in user_sessions.items():
340
- if session_data.get("created_at"):
341
- time_diff = current_time - session_data["created_at"]
342
- if time_diff.total_seconds() > 3600: # 1 hour
343
- sessions_to_remove.append(session_id)
344
-
345
- for session_id in sessions_to_remove:
346
- del user_sessions[session_id]
347
- logger.info(f"Removed old session {session_id[:8]}...")
348
-
349
- if sessions_to_remove:
350
- logger.info(f"Cleaned up {len(sessions_to_remove)} old sessions")
351
 
352
  class GradioUI:
353
  """A one-line interface to launch your agent in Gradio"""
@@ -772,7 +755,7 @@ This AI agent specializes in automated vulnerability research and analysis, buil
772
  # API Key Configuration Section
773
  with gr.Accordion("πŸ”‘ API Configuration", open=False):
774
  gr.Markdown("**Configure your Hugging Face API Key**")
775
- gr.Markdown("πŸ”’ **Security**: Each user has an independent session. Your API key is stored securely and automatically cleared after 1 hour of inactivity.")
776
  gr.Markdown("Get your API key from: https://huggingface.co/settings/tokens")
777
 
778
  api_key_input = gr.Textbox(
@@ -920,7 +903,7 @@ This AI agent specializes in automated vulnerability research and analysis, buil
920
  # API Key Configuration Section for Mobile
921
  with gr.Accordion("πŸ”‘ API Configuration", open=False):
922
  gr.Markdown("**Configure your Hugging Face API Key**")
923
- gr.Markdown("πŸ”’ **Security**: Each user has an independent session. Your API key is stored securely and automatically cleared after 1 hour of inactivity.")
924
  gr.Markdown("Get your API key from: https://huggingface.co/settings/tokens")
925
 
926
  mobile_api_key_input = gr.Textbox(
@@ -1081,19 +1064,7 @@ This AI agent specializes in automated vulnerability research and analysis, buil
1081
  [text_input, launch_research_btn],
1082
  )
1083
 
1084
- # Start periodic cleanup of old sessions
1085
- def periodic_cleanup():
1086
- import time
1087
- while True:
1088
- try:
1089
- cleanup_old_sessions()
1090
- time.sleep(300) # Run every 5 minutes
1091
- except Exception as e:
1092
- logger.error(f"Error in periodic cleanup: {e}")
1093
- time.sleep(300)
1094
-
1095
- cleanup_thread = threading.Thread(target=periodic_cleanup, daemon=True)
1096
- cleanup_thread.start()
1097
 
1098
  demo.launch(debug=True, **kwargs)
1099
 
 
330
  del user_sessions[session_id]["agent"]
331
  logger.info(f"Session {session_id[:8]}... agent cleared")
332
 
333
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
  class GradioUI:
336
  """A one-line interface to launch your agent in Gradio"""
 
755
  # API Key Configuration Section
756
  with gr.Accordion("πŸ”‘ API Configuration", open=False):
757
  gr.Markdown("**Configure your Hugging Face API Key**")
758
+ gr.Markdown("πŸ”’ **Security**: Your API key is only kept during this session.")
759
  gr.Markdown("Get your API key from: https://huggingface.co/settings/tokens")
760
 
761
  api_key_input = gr.Textbox(
 
903
  # API Key Configuration Section for Mobile
904
  with gr.Accordion("πŸ”‘ API Configuration", open=False):
905
  gr.Markdown("**Configure your Hugging Face API Key**")
906
+ gr.Markdown("πŸ”’ **Security**: Your API key is only kept during this session.")
907
  gr.Markdown("Get your API key from: https://huggingface.co/settings/tokens")
908
 
909
  mobile_api_key_input = gr.Textbox(
 
1064
  [text_input, launch_research_btn],
1065
  )
1066
 
1067
+
 
 
 
 
 
 
 
 
 
 
 
 
1068
 
1069
  demo.launch(debug=True, **kwargs)
1070