rufimelo commited on
Commit
be2530a
·
1 Parent(s): 3305332

feat: add file browser to explore all agent-generated outputs and auxiliary files

Browse files
Files changed (1) hide show
  1. streamlit_app.py +65 -0
streamlit_app.py CHANGED
@@ -472,5 +472,70 @@ with tab4:
472
  st.write(f"{similarity}")
473
  with col4:
474
  st.write(f"_{res['Reasoning']}_")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  else:
476
  st.info("No results found to summarize")
 
472
  st.write(f"{similarity}")
473
  with col4:
474
  st.write(f"_{res['Reasoning']}_")
475
+
476
+ # File browser section
477
+ st.markdown("---")
478
+ st.markdown("### 📁 Explore Agent Outputs")
479
+ st.markdown(
480
+ "View all files generated by the agents, including auxiliary .md files, notes, and drafts."
481
+ )
482
+
483
+ # Select paper to browse
484
+ selected_paper_browse = st.selectbox(
485
+ "Select paper to explore files:",
486
+ papers,
487
+ key="file_browser_paper",
488
+ )
489
+
490
+ if selected_paper_browse:
491
+ import os
492
+ from pathlib import Path
493
+
494
+ paper_path = Path("outputs") / selected_paper_browse
495
+ if paper_path.exists():
496
+ # List all files in the paper directory
497
+ files = sorted([f for f in paper_path.iterdir() if f.is_file()])
498
+
499
+ if files:
500
+ st.markdown(f"#### Files in {selected_paper_browse}")
501
+ for file_path in files:
502
+ col1, col2 = st.columns([3, 1])
503
+ with col1:
504
+ st.write(f"📄 `{file_path.name}`")
505
+ with col2:
506
+ # Read and display file
507
+ try:
508
+ if file_path.suffix == ".md":
509
+ with open(file_path, "r") as f:
510
+ content = f.read()
511
+ with st.expander("View", expanded=False):
512
+ st.markdown(content)
513
+ elif file_path.suffix == ".json":
514
+ with open(file_path, "r") as f:
515
+ content = json.load(f)
516
+ with st.expander("View", expanded=False):
517
+ st.json(content)
518
+ elif file_path.suffix == ".txt":
519
+ with open(file_path, "r") as f:
520
+ content = f.read()
521
+ with st.expander("View", expanded=False):
522
+ st.code(content)
523
+ else:
524
+ st.write("(binary or unsupported format)")
525
+ except Exception as e:
526
+ st.write(f"(error: {str(e)})")
527
+
528
+ # Download button
529
+ with open(file_path, "rb") as f:
530
+ st.download_button(
531
+ label="⬇️",
532
+ data=f.read(),
533
+ file_name=file_path.name,
534
+ key=f"download_{file_path.name}",
535
+ )
536
+ else:
537
+ st.info(f"No files found in {selected_paper_browse}")
538
+ else:
539
+ st.error(f"Folder not found for {selected_paper_browse}")
540
  else:
541
  st.info("No results found to summarize")