broadfield-dev commited on
Commit
0b391e3
Β·
verified Β·
1 Parent(s): e7079a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -51
app.py CHANGED
@@ -42,10 +42,6 @@ DEFAULT_SYSTEM_PROMPT = os.getenv(
42
  )
43
  logger.info(f"App Config: WebSearch={WEB_SEARCH_ENABLED}, ToolDecisionProvider={TOOL_DECISION_PROVIDER_ENV}, ToolDecisionModelID={TOOL_DECISION_MODEL_ID_ENV}, MemoryBackend={MEMORY_STORAGE_BACKEND}")
44
 
45
- # --- Helper Functions (format_insights_for_prompt, generate_interaction_metrics, etc.) ---
46
- # These functions (format_insights_for_prompt, generate_interaction_metrics,
47
- # process_user_interaction_gradio, deferred_learning_and_memory_task) remain the same as in the previous "full working file".
48
- # For brevity here, I will not repeat them. Ensure they are present in your actual app.py.
49
  def format_insights_for_prompt(retrieved_insights_list: list[str]) -> tuple[str, list[dict]]:
50
  if not retrieved_insights_list:
51
  return "No specific guiding principles or learned insights retrieved.", []
@@ -302,7 +298,7 @@ def handle_gradio_chat_submit(user_msg_txt: str, gr_hist_list: list, sel_prov_na
302
  with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".md", encoding='utf-8') as tmpfile:
303
  tmpfile.write(curr_bot_disp_msg)
304
  temp_dl_file_path = tmpfile.name
305
- def_dl_btn = gr.DownloadButton(value=temp_dl_file_path, visible=True, interactive=True) # `label` is optional here, Gradio uses filename
306
  else: def_dl_btn = gr.DownloadButton(interactive=False, value=None, visible=False)
307
  insights_md = "### Insights Considered:\n" + ("\n".join([f"- **[{i.get('type','N/A')}|{i.get('score','N/A')}]** {i.get('text','N/A')[:100]}..." for i in insights_used_parsed[:3]]) if insights_used_parsed else "*None specific.*")
308
  def_detect_out_md = gr.Markdown(insights_md)
@@ -384,39 +380,42 @@ def ui_upload_memories_action_fn(uploaded_file_obj, progress=gr.Progress()):
384
 
385
  custom_theme = gr.themes.Base(primary_hue="teal", secondary_hue="purple", neutral_hue="zinc", text_size="sm", spacing_size="md", radius_size="sm", font=["System UI", "sans-serif"])
386
  custom_css = """
387
- body { background: linear-gradient(to bottom right, #2c3e50, #34495e); color: #ecf0f1; min-height: 100vh; }
388
- .gradio-container { background: transparent !important; max-width: 100% !important; padding: 10px !important;}
389
- .gr-box, .gr-panel, .gr-tabs { background-color: rgba(44, 62, 80, 0.85) !important; border-color: rgba(189, 195, 199, 0.2) !important; border-radius: 8px !important;}
390
- .gr-tabitem { background-color: rgba(52, 73, 94, 0.7) !important; border-radius: 6px !important; margin-bottom: 5px !important;}
391
- .gr-accordion { background-color: rgba(52, 73, 94, 0.75) !important; border-radius: 6px !important; }
392
- .gr-textbox, .gr-dropdown, .gr-button, .gr-code, .gr-chat-message, .gr-json { border-color: rgba(189, 195, 199, 0.3) !important; background-color: rgba(52, 73, 94, 0.9) !important; color: #ecf0f1 !important; border-radius: 6px !important;}
393
- .gr-textarea textarea { color: #ecf0f1 !important; } /* Ensure textarea text is light */
 
394
  .gr-button.gr-button-primary { background-color: #1abc9c !important; color: white !important; border-color: #16a085 !important; }
395
  .gr-button.gr-button-secondary { background-color: #9b59b6 !important; color: white !important; border-color: #8e44ad !important; }
396
  .gr-button.gr-button-stop { background-color: #e74c3c !important; color: white !important; border-color: #c0392b !important; }
397
- .gr-markdown { background-color: transparent !important; padding: 0px; border-radius: 0px; } /* Make markdown background transparent within styled boxes */
398
  .gr-markdown h1, .gr-markdown h2, .gr-markdown h3 { color: #1abc9c !important; border-bottom: 1px solid rgba(189, 195, 199, 0.2) !important; padding-bottom: 0.3em; margin-top:1em; }
399
  .gr-markdown p, .gr-markdown li { color: #ecf0f1 !important; }
400
- .gr-markdown pre code { background-color: rgba(30, 40, 50, 0.95) !important; border-color: rgba(189, 195, 199, 0.3) !important; color: #ecf0f1; border-radius: 4px; padding: 0.8em; }
401
- .gr-chatbot { background-color: rgba(44, 62, 80, 0.7) !important; border-color: rgba(189, 195, 199, 0.2) !important; }
402
  .gr-chatbot .message { background-color: rgba(52, 73, 94, 0.9) !important; color: #ecf0f1 !important; border: 1px solid rgba(189, 195, 199, 0.2) !important; box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important; }
403
  .gr-chatbot .message.user { background-color: rgba(46, 204, 113, 0.8) !important; color: #2c3e50 !important; }
404
- .gr-input-label > .label-text, .gr-dropdown-label > .label-text { color: #bdc3c7 !important; font-size: 0.9rem !important; } /* Lighter labels */
405
  .gr-info { color: #bdc3c7 !important; font-size: 0.85rem !important; }
406
- #status_bar_info { background-color: rgba(44, 62, 80, 0.8) !important; padding: 8px; border-radius: 6px; margin-bottom: 10px; }
 
 
 
407
  """
408
 
409
- with gr.Blocks(theme=custom_theme, css=custom_css, title="AI Research Mega Agent v5.1") as demo:
410
  gr.Markdown("# πŸš€ AI Research Mega Agent Dashboard")
411
 
412
  avail_provs = get_available_providers()
413
  def_prov = avail_provs[0] if avail_provs else None
414
  def_models = get_model_display_names_for_provider(def_prov) if def_prov else []
415
  def_model_disp = get_default_model_display_name_for_provider(def_prov) if def_prov else None
416
- save_faiss_ram_btn_kb = None # For KB tab
417
-
418
- with gr.Row(elem_id="status_bar_info"):
419
- with gr.Column(scale=2): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
420
  with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
421
  if MEMORY_STORAGE_BACKEND == "SQLITE":
422
  with gr.Column(scale=2): gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False)
@@ -424,28 +423,28 @@ with gr.Blocks(theme=custom_theme, css=custom_css, title="AI Research Mega Agent
424
  with gr.Column(scale=2): gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False)
425
 
426
  with gr.Tabs() as main_tabs:
427
- with gr.TabItem("βš™οΈ Agent Configuration & Chat", id=0):
428
- with gr.Row():
429
- with gr.Column(scale=1, min_width=350):
430
- gr.Markdown("## βš™οΈ LLM & System Configuration")
431
  with gr.Group():
432
  prov_sel_dd = gr.Dropdown(label="AI Provider", choices=avail_provs, value=def_prov, interactive=True)
433
  model_sel_dd = gr.Dropdown(label="AI Model", choices=def_models, value=def_model_disp, interactive=True)
434
  api_key_tb = gr.Textbox(label="API Key Override (Optional)", type="password", placeholder="Paste key for selected provider")
435
  with gr.Group():
436
- sys_prompt_tb = gr.Textbox(label="System Prompt Base", lines=10, value=DEFAULT_SYSTEM_PROMPT, interactive=True)
437
 
438
- with gr.Column(scale=2):
439
  gr.Markdown("## πŸ’¬ AI Chat Interface")
440
  main_chat_disp = gr.Chatbot(label="AI Research Chat", height=550, bubble_full_width=False, avatar_images=(None, "https://raw.githubusercontent.com/huggingface/brand-assets/main/hf-logo-with-title.png"), show_copy_button=True, render_markdown=True, sanitize_html=True)
441
  with gr.Row():
442
  user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question or give an instruction...", scale=7, lines=1, max_lines=5, autofocus=True)
443
  send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
444
 
445
- with gr.Accordion("πŸ“ Full Response / Output Details", open=False):
446
  fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True, value="*AI responses will appear here...*")
447
  dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
448
- detect_out_md = gr.Markdown("*Insights used or other intermediate details will show here...*")
449
 
450
  with gr.TabItem("🧠 Knowledge Base Management", id=1):
451
  gr.Markdown("## Manage Stored Knowledge")
@@ -455,19 +454,18 @@ with gr.Blocks(theme=custom_theme, css=custom_css, title="AI Research Mega Agent
455
  rules_disp_ta = gr.TextArea(label="View/Edit Rules (one per line or '---' separated)", lines=15, interactive=True, placeholder="Load or type rules here...")
456
  with gr.Row():
457
  view_rules_btn = gr.Button("πŸ”„ Load/Refresh Rules"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edited Rules", variant="primary")
458
- upload_rules_fobj = gr.File(label="Upload Rules File (.txt/.jsonl)", file_types=[".txt", ".jsonl"])
459
- rules_stat_tb = gr.Textbox(label="Rules Op Status", interactive=False, lines=2, placeholder="Status...")
460
  with gr.Row():
461
  clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
462
- if MEMORY_STORAGE_BACKEND == "RAM":
463
- save_faiss_ram_btn_kb = gr.Button("Save FAISS Indices")
464
 
465
  with gr.Column(scale=1):
466
  gr.Markdown("### πŸ“š Memories (Past Interactions)")
467
- mems_disp_json = gr.JSON(label="View Memories (JSON format)", scale=2)
468
  with gr.Row(): view_mems_btn = gr.Button("πŸ”„ Load/Refresh Memories")
469
  upload_mems_fobj = gr.File(label="Upload Memories File (.jsonl)", file_types=[".jsonl"])
470
- mems_stat_tb = gr.Textbox(label="Memories Op Status", interactive=False, lines=2, placeholder="Status...")
471
  clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
472
 
473
  def dyn_upd_model_dd(sel_prov_dyn:str): models_dyn, def_model_dyn = get_model_display_names_for_provider(sel_prov_dyn), get_default_model_display_name_for_provider(sel_prov_dyn); return gr.Dropdown(choices=models_dyn, value=def_model_dyn, interactive=True)
@@ -508,29 +506,17 @@ with gr.Blocks(theme=custom_theme, css=custom_css, title="AI Research Mega Agent
508
  def app_load_fn():
509
  initialize_memory_system()
510
  logger.info("App loaded. Memory system initialized.")
511
- backend_status = f"AI Systems Initialized. Ready." # Agent status, backend info is separate
512
  rules_on_load = ui_view_rules_action_fn()
513
  mems_on_load = ui_view_memories_action_fn()
514
- # Update memory backend info text box too
515
- mem_backend_text = f"{MEMORY_STORAGE_BACKEND}"
516
- if MEMORY_STORAGE_BACKEND == "SQLITE": mem_backend_path_text = f"{MEMORY_SQLITE_PATH}"
517
- elif MEMORY_STORAGE_BACKEND == "HF_DATASET": mem_backend_path_text = f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}"
518
- else: mem_backend_path_text = "N/A" # For RAM
519
-
520
- # The number of outputs from app_load_fn must match the number of components in demo.load's outputs list
521
- # Make sure memory_backend_info_tb and its potential path display are updated if they are separate components
522
- # The current UI has one tb for backend and one for path (conditional)
523
- # For simplicity here, I'll assume they are part of the static display or updated differently if needed.
524
- # The agent_stat_tb is the primary one to update here.
525
  return backend_status, rules_on_load, mems_on_load
526
 
527
- # Update outputs of demo.load to populate the KB views on startup
528
  demo.load(fn=app_load_fn, inputs=None, outputs=[agent_stat_tb, rules_disp_ta, mems_disp_json])
529
 
530
  if __name__ == "__main__":
531
- logger.info(f"Starting Gradio AI Research Mega Agent (v5.1 with New UI & Advanced Memory: {MEMORY_STORAGE_BACKEND})...")
532
  app_port, app_server = int(os.getenv("GRADIO_PORT", 7860)), os.getenv("GRADIO_SERVER_NAME", "127.0.0.1")
533
  app_debug, app_share = os.getenv("GRADIO_DEBUG", "False").lower()=="true", os.getenv("GRADIO_SHARE", "False").lower()=="true"
534
  logger.info(f"Launching Gradio server: http://{app_server}:{app_port}. Debug: {app_debug}, Share: {app_share}")
535
- demo.queue().launch(server_name=app_server, server_port=app_port, debug=app_debug, share=app_share)
536
  logger.info("Gradio application shut down.")
 
42
  )
43
  logger.info(f"App Config: WebSearch={WEB_SEARCH_ENABLED}, ToolDecisionProvider={TOOL_DECISION_PROVIDER_ENV}, ToolDecisionModelID={TOOL_DECISION_MODEL_ID_ENV}, MemoryBackend={MEMORY_STORAGE_BACKEND}")
44
 
 
 
 
 
45
  def format_insights_for_prompt(retrieved_insights_list: list[str]) -> tuple[str, list[dict]]:
46
  if not retrieved_insights_list:
47
  return "No specific guiding principles or learned insights retrieved.", []
 
298
  with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".md", encoding='utf-8') as tmpfile:
299
  tmpfile.write(curr_bot_disp_msg)
300
  temp_dl_file_path = tmpfile.name
301
+ def_dl_btn = gr.DownloadButton(value=temp_dl_file_path, visible=True, interactive=True)
302
  else: def_dl_btn = gr.DownloadButton(interactive=False, value=None, visible=False)
303
  insights_md = "### Insights Considered:\n" + ("\n".join([f"- **[{i.get('type','N/A')}|{i.get('score','N/A')}]** {i.get('text','N/A')[:100]}..." for i in insights_used_parsed[:3]]) if insights_used_parsed else "*None specific.*")
304
  def_detect_out_md = gr.Markdown(insights_md)
 
380
 
381
  custom_theme = gr.themes.Base(primary_hue="teal", secondary_hue="purple", neutral_hue="zinc", text_size="sm", spacing_size="md", radius_size="sm", font=["System UI", "sans-serif"])
382
  custom_css = """
383
+ body { background: linear-gradient(to bottom right, #2c3e50, #34495e); color: #ecf0f1; min-height: 100vh; margin:0; padding:0;}
384
+ .gradio-container { background: transparent !important; max-width: 100% !important; padding: 1rem !important; box-sizing: border-box;}
385
+ .gr-box, .gr-panel, .gr-tabs, .gr-accordion { background-color: rgba(44, 62, 80, 0.85) !important; border: 1px solid rgba(189, 195, 199, 0.2) !important; border-radius: 8px !important; box-shadow: 0 4px 6px rgba(0,0,0,0.1);}
386
+ .gr-tabitem { background-color: rgba(52, 73, 94, 0.7) !important; border-radius: 6px !important; margin-bottom: 5px !important; padding: 1em !important;}
387
+ .gr-textbox, .gr-dropdown, .gr-button, .gr-code, .gr-chat-message, .gr-json, .gr-file input[type="file"] { border: 1px solid rgba(189, 195, 199, 0.3) !important; background-color: rgba(52, 73, 94, 0.9) !important; color: #ecf0f1 !important; border-radius: 6px !important;}
388
+ .gr-file { background-color: rgba(52, 73, 94, 0.9) !important; border-radius: 6px !important; padding: 0.5em;}
389
+ .gr-file > .label-text { color: #bdc3c7 !important;}
390
+ .gr-textarea textarea, .gr-textbox input { color: #ecf0f1 !important; }
391
  .gr-button.gr-button-primary { background-color: #1abc9c !important; color: white !important; border-color: #16a085 !important; }
392
  .gr-button.gr-button-secondary { background-color: #9b59b6 !important; color: white !important; border-color: #8e44ad !important; }
393
  .gr-button.gr-button-stop { background-color: #e74c3c !important; color: white !important; border-color: #c0392b !important; }
394
+ .gr-markdown { background-color: transparent !important; padding: 0px; }
395
  .gr-markdown h1, .gr-markdown h2, .gr-markdown h3 { color: #1abc9c !important; border-bottom: 1px solid rgba(189, 195, 199, 0.2) !important; padding-bottom: 0.3em; margin-top:1em; }
396
  .gr-markdown p, .gr-markdown li { color: #ecf0f1 !important; }
397
+ .gr-markdown pre code { background-color: rgba(30, 40, 50, 0.95) !important; border: 1px solid rgba(189, 195, 199, 0.3) !important; color: #ecf0f1; border-radius: 4px; padding: 0.8em; }
398
+ .gr-chatbot { background-color: rgba(44, 62, 80, 0.7) !important; border: 1px solid rgba(189, 195, 199, 0.2) !important; }
399
  .gr-chatbot .message { background-color: rgba(52, 73, 94, 0.9) !important; color: #ecf0f1 !important; border: 1px solid rgba(189, 195, 199, 0.2) !important; box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important; }
400
  .gr-chatbot .message.user { background-color: rgba(46, 204, 113, 0.8) !important; color: #2c3e50 !important; }
401
+ .gr-input-label > .label-text, .gr-dropdown-label > .label-text, .gr-checkbox-label > .label-text { color: #bdc3c7 !important; font-size: 0.9rem !important; }
402
  .gr-info { color: #bdc3c7 !important; font-size: 0.85rem !important; }
403
+ #status_bar_group { background-color: rgba(44, 62, 80, 0.8) !important; padding: 8px; border-radius: 6px; margin-bottom: 10px; }
404
+ .tabnav button { background-color: rgba(52, 73, 94, 0.8) !important; color: #ecf0f1 !important; border-bottom: 2px solid transparent !important;}
405
+ .tabnav button.selected { background-color: rgba(44, 62, 80, 0.95) !important; color: #1abc9c !important; border-bottom: 2px solid #1abc9c !important;}
406
+ .gr-block.gr-box { padding: 1em; } /* Add some padding to groups/boxes */
407
  """
408
 
409
+ with gr.Blocks(theme=custom_theme, css=custom_css, title="AI Research Mega Agent v5.2") as demo:
410
  gr.Markdown("# πŸš€ AI Research Mega Agent Dashboard")
411
 
412
  avail_provs = get_available_providers()
413
  def_prov = avail_provs[0] if avail_provs else None
414
  def_models = get_model_display_names_for_provider(def_prov) if def_prov else []
415
  def_model_disp = get_default_model_display_name_for_provider(def_prov) if def_prov else None
416
+
417
+ with gr.Row(elem_id="status_bar_group"):
418
+ with gr.Column(scale=3): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
 
419
  with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
420
  if MEMORY_STORAGE_BACKEND == "SQLITE":
421
  with gr.Column(scale=2): gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False)
 
423
  with gr.Column(scale=2): gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False)
424
 
425
  with gr.Tabs() as main_tabs:
426
+ with gr.TabItem("βš™οΈ Config & πŸ’¬ Chat", id=0):
427
+ with gr.Row(equal_height=False):
428
+ with gr.Column(scale=1, min_width=380): # Sidebar for config
429
+ gr.Markdown("## βš™οΈ LLM Configuration")
430
  with gr.Group():
431
  prov_sel_dd = gr.Dropdown(label="AI Provider", choices=avail_provs, value=def_prov, interactive=True)
432
  model_sel_dd = gr.Dropdown(label="AI Model", choices=def_models, value=def_model_disp, interactive=True)
433
  api_key_tb = gr.Textbox(label="API Key Override (Optional)", type="password", placeholder="Paste key for selected provider")
434
  with gr.Group():
435
+ sys_prompt_tb = gr.Textbox(label="System Prompt Base", lines=12, value=DEFAULT_SYSTEM_PROMPT, interactive=True)
436
 
437
+ with gr.Column(scale=2): # Main chat area
438
  gr.Markdown("## πŸ’¬ AI Chat Interface")
439
  main_chat_disp = gr.Chatbot(label="AI Research Chat", height=550, bubble_full_width=False, avatar_images=(None, "https://raw.githubusercontent.com/huggingface/brand-assets/main/hf-logo-with-title.png"), show_copy_button=True, render_markdown=True, sanitize_html=True)
440
  with gr.Row():
441
  user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question or give an instruction...", scale=7, lines=1, max_lines=5, autofocus=True)
442
  send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
443
 
444
+ with gr.Accordion("πŸ“ Full Response / Output Details", open=False, elem_id="response_accordion"):
445
  fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True, value="*AI responses will appear here...*")
446
  dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
447
+ detect_out_md = gr.Markdown("*Insights used or other intermediate details will show here...*")
448
 
449
  with gr.TabItem("🧠 Knowledge Base Management", id=1):
450
  gr.Markdown("## Manage Stored Knowledge")
 
454
  rules_disp_ta = gr.TextArea(label="View/Edit Rules (one per line or '---' separated)", lines=15, interactive=True, placeholder="Load or type rules here...")
455
  with gr.Row():
456
  view_rules_btn = gr.Button("πŸ”„ Load/Refresh Rules"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edited Rules", variant="primary")
457
+ upload_rules_fobj = gr.File(label="Upload Rules File (.txt or .jsonl)", file_types=[".txt", ".jsonl"])
458
+ rules_stat_tb = gr.Textbox(label="Rules Operation Status", interactive=False, lines=2, placeholder="Status of rule operations...")
459
  with gr.Row():
460
  clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
461
+ save_faiss_ram_btn_kb = gr.Button("Save FAISS Indices", visible=(MEMORY_STORAGE_BACKEND == "RAM"))
 
462
 
463
  with gr.Column(scale=1):
464
  gr.Markdown("### πŸ“š Memories (Past Interactions)")
465
+ mems_disp_json = gr.JSON(label="View Memories (JSON format)", scale=2) # scale might not work directly on gr.JSON
466
  with gr.Row(): view_mems_btn = gr.Button("πŸ”„ Load/Refresh Memories")
467
  upload_mems_fobj = gr.File(label="Upload Memories File (.jsonl)", file_types=[".jsonl"])
468
+ mems_stat_tb = gr.Textbox(label="Memories Operation Status", interactive=False, lines=2, placeholder="Status of memory operations...")
469
  clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
470
 
471
  def dyn_upd_model_dd(sel_prov_dyn:str): models_dyn, def_model_dyn = get_model_display_names_for_provider(sel_prov_dyn), get_default_model_display_name_for_provider(sel_prov_dyn); return gr.Dropdown(choices=models_dyn, value=def_model_dyn, interactive=True)
 
506
  def app_load_fn():
507
  initialize_memory_system()
508
  logger.info("App loaded. Memory system initialized.")
509
+ backend_status = f"AI Systems Initialized. Ready."
510
  rules_on_load = ui_view_rules_action_fn()
511
  mems_on_load = ui_view_memories_action_fn()
 
 
 
 
 
 
 
 
 
 
 
512
  return backend_status, rules_on_load, mems_on_load
513
 
 
514
  demo.load(fn=app_load_fn, inputs=None, outputs=[agent_stat_tb, rules_disp_ta, mems_disp_json])
515
 
516
  if __name__ == "__main__":
517
+ logger.info(f"Starting Gradio AI Research Mega Agent (v5.2 with Dashboard UI & Advanced Memory: {MEMORY_STORAGE_BACKEND})...")
518
  app_port, app_server = int(os.getenv("GRADIO_PORT", 7860)), os.getenv("GRADIO_SERVER_NAME", "127.0.0.1")
519
  app_debug, app_share = os.getenv("GRADIO_DEBUG", "False").lower()=="true", os.getenv("GRADIO_SHARE", "False").lower()=="true"
520
  logger.info(f"Launching Gradio server: http://{app_server}:{app_port}. Debug: {app_debug}, Share: {app_share}")
521
+ demo.queue().launch(server_name=app_server, server_port=app_port, debug=app_debug, share=app_share, fill_height=True) # Added fill_height
522
  logger.info("Gradio application shut down.")