broadfield-dev commited on
Commit
42140eb
Β·
verified Β·
1 Parent(s): b1cc313

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -41
app.py CHANGED
@@ -447,53 +447,52 @@ with gr.Blocks(title="AI Research Agent v5.8") as demo:
447
  sys_prompt_tb = gr.Textbox(label="System Prompt Base", lines=10, value=DEFAULT_SYSTEM_PROMPT, interactive=True)
448
  if MEMORY_STORAGE_BACKEND == "RAM":
449
  save_faiss_sidebar_btn = gr.Button("Save FAISS Indices", variant="secondary")
450
- with gr.Column(): # New overall wrapper for content
451
- with gr.Row():
452
- gr.Markdown("# πŸ€– AI Research Agent")
453
- # Removed subtitle from here, can be added in description of Space if hosted on HF
454
 
455
 
456
-
457
- with gr.Row(elem_classes="status-bar"):
458
- with gr.Column(scale=3): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
459
- with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
460
- sqlite_path_display = gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False, visible=(MEMORY_STORAGE_BACKEND == "SQLITE"), scale=2) # Use visible
461
- hf_repos_display = gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False, visible=(MEMORY_STORAGE_BACKEND == "HF_DATASET"), scale=2) # Use visible
462
 
463
 
464
 
465
- with gr.Column(scale=3): # Main content area to the right of sidebar
466
- with gr.Tabs():
467
- with gr.TabItem("πŸ’¬ AI Chat & Research Output"):
468
- gr.Markdown("### AI Chat Interface") # Using H3 for section titles within tabs
469
- main_chat_disp = gr.Chatbot(label="AI Research Chat", height=500, 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)
470
- with gr.Row():
471
- user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question...", scale=7, lines=1, max_lines=5, autofocus=True)
472
- send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
473
- with gr.Accordion("πŸ“ Full Response / Details", open=False):
474
- fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True)
475
- dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
476
- detect_out_md = gr.Markdown()
477
 
478
- with gr.TabItem("🧠 Knowledge Base Management"):
479
- gr.Markdown("### Manage Stored Knowledge")
480
- with gr.Row():
481
- with gr.Column():
482
- with gr.Group():
483
- gr.Markdown("#### πŸ“œ Rules (Insights)")
484
- rules_disp_ta = gr.TextArea(label="View/Edit Rules", lines=15, interactive=True, placeholder="Load rules or type new ones...")
485
- with gr.Row(): view_rules_btn = gr.Button("πŸ”„ Load"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edits", variant="primary")
486
- upload_rules_fobj = gr.File(label="Upload Rules File", file_types=[".txt", ".jsonl"])
487
- rules_stat_tb = gr.Textbox(label="Rules Status", interactive=False, lines=2)
488
- clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
489
- with gr.Column():
490
- with gr.Group():
491
- gr.Markdown("#### πŸ“š Memories")
492
- mems_disp_json = gr.JSON(label="View Memories")
493
- view_mems_btn = gr.Button("πŸ”„ Load Memories")
494
- upload_mems_fobj = gr.File(label="Upload Memories File", file_types=[".jsonl"])
495
- mems_stat_tb = gr.Textbox(label="Memories Status", interactive=False, lines=2)
496
- clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
497
 
498
  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)
499
  prov_sel_dd.change(fn=dyn_upd_model_dd, inputs=prov_sel_dd, outputs=model_sel_dd)
 
447
  sys_prompt_tb = gr.Textbox(label="System Prompt Base", lines=10, value=DEFAULT_SYSTEM_PROMPT, interactive=True)
448
  if MEMORY_STORAGE_BACKEND == "RAM":
449
  save_faiss_sidebar_btn = gr.Button("Save FAISS Indices", variant="secondary")
450
+ with gr.Row():
451
+ gr.Markdown("# πŸ€– AI Research Agent")
452
+ # Removed subtitle from here, can be added in description of Space if hosted on HF
 
453
 
454
 
455
+
456
+ with gr.Row(elem_classes="status-bar"):
457
+ with gr.Column(scale=3): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
458
+ with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
459
+ sqlite_path_display = gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False, visible=(MEMORY_STORAGE_BACKEND == "SQLITE"), scale=2) # Use visible
460
+ hf_repos_display = gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False, visible=(MEMORY_STORAGE_BACKEND == "HF_DATASET"), scale=2) # Use visible
461
 
462
 
463
 
464
+ with gr.Row(scale=3): # Main content area to the right of sidebar
465
+ with gr.Tabs():
466
+ with gr.TabItem("πŸ’¬ AI Chat & Research Output"):
467
+ gr.Markdown("### AI Chat Interface") # Using H3 for section titles within tabs
468
+ main_chat_disp = gr.Chatbot(label="AI Research Chat", height=500, 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)
469
+ with gr.Row():
470
+ user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question...", scale=7, lines=1, max_lines=5, autofocus=True)
471
+ send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
472
+ with gr.Accordion("πŸ“ Full Response / Details", open=False):
473
+ fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True)
474
+ dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
475
+ detect_out_md = gr.Markdown()
476
 
477
+ with gr.TabItem("🧠 Knowledge Base Management"):
478
+ gr.Markdown("### Manage Stored Knowledge")
479
+ with gr.Row():
480
+ with gr.Column():
481
+ with gr.Group():
482
+ gr.Markdown("#### πŸ“œ Rules (Insights)")
483
+ rules_disp_ta = gr.TextArea(label="View/Edit Rules", lines=15, interactive=True, placeholder="Load rules or type new ones...")
484
+ with gr.Row(): view_rules_btn = gr.Button("πŸ”„ Load"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edits", variant="primary")
485
+ upload_rules_fobj = gr.File(label="Upload Rules File", file_types=[".txt", ".jsonl"])
486
+ rules_stat_tb = gr.Textbox(label="Rules Status", interactive=False, lines=2)
487
+ clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
488
+ with gr.Column():
489
+ with gr.Group():
490
+ gr.Markdown("#### πŸ“š Memories")
491
+ mems_disp_json = gr.JSON(label="View Memories")
492
+ view_mems_btn = gr.Button("πŸ”„ Load Memories")
493
+ upload_mems_fobj = gr.File(label="Upload Memories File", file_types=[".jsonl"])
494
+ mems_stat_tb = gr.Textbox(label="Memories Status", interactive=False, lines=2)
495
+ clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
496
 
497
  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)
498
  prov_sel_dd.change(fn=dyn_upd_model_dd, inputs=prov_sel_dd, outputs=model_sel_dd)