broadfield-dev commited on
Commit
2e1d151
Β·
verified Β·
1 Parent(s): 86c1347

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -40
app.py CHANGED
@@ -431,6 +431,13 @@ body { background: linear-gradient(to bottom right, #2c3e50, #34495e); color: #e
431
  """
432
 
433
  with gr.Blocks(title="AI Research Agent v5.8") as demo:
 
 
 
 
 
 
 
434
  avail_provs = get_available_providers()
435
  def_prov = avail_provs[0] if avail_provs else None
436
  def_models = get_model_display_names_for_provider(def_prov) if def_prov else []
@@ -447,46 +454,38 @@ 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.Group():
451
- with gr.Row():
452
- gr.Markdown("# πŸ€– AI Research Agent")
453
- with gr.Row():
454
- with gr.Column(scale=3): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
455
- with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
456
- sqlite_path_display = gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False, scale=2) # Use visible
457
- hf_repos_display = gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False, scale=2) # Use visible
458
-
459
- with gr.Tabs():
460
- with gr.TabItem("πŸ’¬ AI Chat & Research Output"):
461
- gr.Markdown("### AI Chat Interface") # Using H3 for section titles within tabs
462
- 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)
463
- with gr.Row():
464
- user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question...", scale=7, lines=1, max_lines=5, autofocus=True)
465
- send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
466
- with gr.Accordion("πŸ“ Full Response / Details", open=False):
467
- fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True)
468
- dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
469
- detect_out_md = gr.Markdown()
470
-
471
- with gr.TabItem("🧠 Knowledge Base Management"):
472
- gr.Markdown("### Manage Stored Knowledge")
473
- with gr.Row():
474
- with gr.Column():
475
- with gr.Group():
476
- gr.Markdown("#### πŸ“œ Rules (Insights)")
477
- rules_disp_ta = gr.TextArea(label="View/Edit Rules", lines=15, interactive=True, placeholder="Load rules or type new ones...")
478
- with gr.Row(): view_rules_btn = gr.Button("πŸ”„ Load"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edits", variant="primary")
479
- upload_rules_fobj = gr.File(label="Upload Rules File", file_types=[".txt", ".jsonl"])
480
- rules_stat_tb = gr.Textbox(label="Rules Status", interactive=False, lines=2)
481
- clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
482
- with gr.Column():
483
- with gr.Group():
484
- gr.Markdown("#### πŸ“š Memories")
485
- mems_disp_json = gr.JSON(label="View Memories")
486
- view_mems_btn = gr.Button("πŸ”„ Load Memories")
487
- upload_mems_fobj = gr.File(label="Upload Memories File", file_types=[".jsonl"])
488
- mems_stat_tb = gr.Textbox(label="Memories Status", interactive=False, lines=2)
489
- clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
490
 
491
  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)
492
  prov_sel_dd.change(fn=dyn_upd_model_dd, inputs=prov_sel_dd, outputs=model_sel_dd)
 
431
  """
432
 
433
  with gr.Blocks(title="AI Research Agent v5.8") as demo:
434
+ gr.Markdown("# πŸ€– AI Research Agent")
435
+ with gr.Row():
436
+ with gr.Column(scale=3): agent_stat_tb = gr.Textbox(label="Agent Status", interactive=False, lines=1, value="Initializing systems...")
437
+ with gr.Column(scale=1): memory_backend_info_tb = gr.Textbox(label="Memory Backend", value=f"{MEMORY_STORAGE_BACKEND}", interactive=False)
438
+ sqlite_path_display = gr.Textbox(label="SQLite Path", value=f"{MEMORY_SQLITE_PATH}", interactive=False, scale=2) # Use visible
439
+ hf_repos_display = gr.Textbox(label="HF Repos", value=f"M: {MEMORY_HF_MEM_REPO}, R: {MEMORY_HF_RULES_REPO}", interactive=False, scale=2) # Use visible
440
+
441
  avail_provs = get_available_providers()
442
  def_prov = avail_provs[0] if avail_provs else None
443
  def_models = get_model_display_names_for_provider(def_prov) if def_prov else []
 
454
  sys_prompt_tb = gr.Textbox(label="System Prompt Base", lines=10, value=DEFAULT_SYSTEM_PROMPT, interactive=True)
455
  if MEMORY_STORAGE_BACKEND == "RAM":
456
  save_faiss_sidebar_btn = gr.Button("Save FAISS Indices", variant="secondary")
457
+
458
+ with gr.Tabs():
459
+ with gr.TabItem("πŸ’¬ AI Chat & Research Output"):
460
+ gr.Markdown("### AI Chat Interface") # Using H3 for section titles within tabs
461
+ 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)
462
+ with gr.Row():
463
+ user_msg_tb = gr.Textbox(show_label=False, placeholder="Ask your research question...", scale=7, lines=1, max_lines=5, autofocus=True)
464
+ send_btn = gr.Button("Send", variant="primary", scale=1, min_width=100)
465
+ with gr.Accordion("πŸ“ Full Response / Details", open=False):
466
+ fmt_report_tb = gr.Textbox(label="Full AI Response", lines=10, interactive=True, show_copy_button=True)
467
+ dl_report_btn = gr.DownloadButton("Download Report", interactive=False, visible=False)
468
+ detect_out_md = gr.Markdown()
469
+
470
+ with gr.TabItem("🧠 Knowledge Base Management"):
471
+ gr.Markdown("### Manage Stored Knowledge")
472
+ with gr.Row():
473
+ with gr.Column():
474
+ with gr.Group():
475
+ gr.Markdown("#### πŸ“œ Rules (Insights)")
476
+ rules_disp_ta = gr.TextArea(label="View/Edit Rules", lines=15, interactive=True, placeholder="Load rules or type new ones...")
477
+ with gr.Row(): view_rules_btn = gr.Button("πŸ”„ Load"); save_edited_rules_btn = gr.Button("πŸ’Ύ Save Edits", variant="primary")
478
+ upload_rules_fobj = gr.File(label="Upload Rules File", file_types=[".txt", ".jsonl"])
479
+ rules_stat_tb = gr.Textbox(label="Rules Status", interactive=False, lines=2)
480
+ clear_rules_btn = gr.Button("⚠️ Clear All Rules", variant="stop")
481
+ with gr.Column():
482
+ with gr.Group():
483
+ gr.Markdown("#### πŸ“š Memories")
484
+ mems_disp_json = gr.JSON(label="View Memories")
485
+ view_mems_btn = gr.Button("πŸ”„ Load Memories")
486
+ upload_mems_fobj = gr.File(label="Upload Memories File", file_types=[".jsonl"])
487
+ mems_stat_tb = gr.Textbox(label="Memories Status", interactive=False, lines=2)
488
+ clear_mems_btn = gr.Button("⚠️ Clear All Memories", variant="stop")
 
 
 
 
 
 
 
 
489
 
490
  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)
491
  prov_sel_dd.change(fn=dyn_upd_model_dd, inputs=prov_sel_dd, outputs=model_sel_dd)