Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -191,7 +191,7 @@ def search_arxiv(query):
|
|
191 |
Answer = response2
|
192 |
SpeechSynthesis(Answer)
|
193 |
# Restructure results to follow format of Question, Answer, References, ReferenceLinks
|
194 |
-
results = Question + Answer + References + ReferenceLinks
|
195 |
st.markdown(results)
|
196 |
|
197 |
st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
|
@@ -569,33 +569,9 @@ def FileSidebar():
|
|
569 |
# File Sidebar for files 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
|
570 |
all_files = glob.glob("*.md")
|
571 |
all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
572 |
-
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by
|
573 |
-
|
574 |
-
# Compare file sizes for potential duplicates
|
575 |
-
file_sizes = [get_file_size(file) for file in all_files]
|
576 |
-
previous_size = None
|
577 |
|
578 |
|
579 |
-
# User interface
|
580 |
-
st.sidebar.title("File Operations")
|
581 |
-
for file, size in zip(all_files, file_sizes):
|
582 |
-
duplicate_flag = "🚩" if size == previous_size else ""
|
583 |
-
with st.sidebar.expander(f"File: {file} {duplicate_flag}"):
|
584 |
-
st.text(f"Size: {size} bytes")
|
585 |
-
|
586 |
-
if st.button("View", key=f"view_{file}"):
|
587 |
-
try:
|
588 |
-
with open(file, "r", encoding='utf-8') as f: # Ensure the file is read with UTF-8 encoding
|
589 |
-
file_content = f.read()
|
590 |
-
st.code(file_content, language="markdown")
|
591 |
-
except UnicodeDecodeError:
|
592 |
-
st.error("Failed to decode the file with UTF-8. It might contain non-UTF-8 encoded characters.")
|
593 |
-
|
594 |
-
if st.button("Delete", key=f"delete3_{file}"):
|
595 |
-
os.remove(file)
|
596 |
-
st.rerun()
|
597 |
-
previous_size = size # Update previous size for the next iteration
|
598 |
-
|
599 |
|
600 |
# Button to compare files and delete duplicates
|
601 |
#if st.button("Compare and Delete Duplicates"):
|
@@ -603,7 +579,7 @@ def FileSidebar():
|
|
603 |
|
604 |
|
605 |
|
606 |
-
|
607 |
Files1, Files2 = st.sidebar.columns(2)
|
608 |
with Files1:
|
609 |
if st.button("🗑 Delete All"):
|
@@ -618,6 +594,7 @@ def FileSidebar():
|
|
618 |
file_name=''
|
619 |
next_action=''
|
620 |
|
|
|
621 |
# Add files 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
|
622 |
for file in all_files:
|
623 |
col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
|
@@ -653,6 +630,28 @@ def FileSidebar():
|
|
653 |
st.session_state['next_action'] = next_action
|
654 |
|
655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
656 |
if len(file_contents) > 0:
|
657 |
if next_action=='open': # For "open", prep session state if it hasn't been yet
|
658 |
if 'lastfilename' not in st.session_state:
|
@@ -667,13 +666,16 @@ def FileSidebar():
|
|
667 |
# Use onchange functions to autoexecute file name and text save functions.
|
668 |
file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
|
669 |
file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=300)
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
|
|
|
|
|
|
677 |
|
678 |
new_file_content_area = st.session_state['file_content_area']
|
679 |
if new_file_content_area != file_contents:
|
|
|
191 |
Answer = response2
|
192 |
SpeechSynthesis(Answer)
|
193 |
# Restructure results to follow format of Question, Answer, References, ReferenceLinks
|
194 |
+
results = Question + '\r\n' + Answer + '\r\n' + References + '\r\n' + ReferenceLinks
|
195 |
st.markdown(results)
|
196 |
|
197 |
st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
|
|
|
569 |
# File Sidebar for files 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
|
570 |
all_files = glob.glob("*.md")
|
571 |
all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
572 |
+
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by filename length which puts similar prompts together - consider making date and time of file optional.
|
|
|
|
|
|
|
|
|
573 |
|
574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
# Button to compare files and delete duplicates
|
577 |
#if st.button("Compare and Delete Duplicates"):
|
|
|
579 |
|
580 |
|
581 |
|
582 |
+
# ⬇️ Download
|
583 |
Files1, Files2 = st.sidebar.columns(2)
|
584 |
with Files1:
|
585 |
if st.button("🗑 Delete All"):
|
|
|
594 |
file_name=''
|
595 |
next_action=''
|
596 |
|
597 |
+
|
598 |
# Add files 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
|
599 |
for file in all_files:
|
600 |
col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
|
|
|
630 |
st.session_state['next_action'] = next_action
|
631 |
|
632 |
|
633 |
+
# 🚩File duplicate detector - useful to prune and view all. Pruning works well by file size detection of two similar and flags the duplicate.
|
634 |
+
file_sizes = [get_file_size(file) for file in all_files]
|
635 |
+
previous_size = None
|
636 |
+
st.sidebar.title("File Operations")
|
637 |
+
for file, size in zip(all_files, file_sizes):
|
638 |
+
duplicate_flag = "🚩" if size == previous_size else ""
|
639 |
+
with st.sidebar.expander(f"File: {file} {duplicate_flag}"):
|
640 |
+
st.text(f"Size: {size} bytes")
|
641 |
+
|
642 |
+
if st.button("View", key=f"view_{file}"):
|
643 |
+
try:
|
644 |
+
with open(file, "r", encoding='utf-8') as f: # Ensure the file is read with UTF-8 encoding
|
645 |
+
file_content = f.read()
|
646 |
+
st.code(file_content, language="markdown")
|
647 |
+
except UnicodeDecodeError:
|
648 |
+
st.error("Failed to decode the file with UTF-8. It might contain non-UTF-8 encoded characters.")
|
649 |
+
|
650 |
+
if st.button("Delete", key=f"delete3_{file}"):
|
651 |
+
os.remove(file)
|
652 |
+
st.rerun()
|
653 |
+
previous_size = size # Update previous size for the next iteration
|
654 |
+
|
655 |
if len(file_contents) > 0:
|
656 |
if next_action=='open': # For "open", prep session state if it hasn't been yet
|
657 |
if 'lastfilename' not in st.session_state:
|
|
|
666 |
# Use onchange functions to autoexecute file name and text save functions.
|
667 |
file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
|
668 |
file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=300)
|
669 |
+
|
670 |
+
ShowButtons = False # Having buttons is redundant. They work but if on change event seals the deal so be it - faster save is less impedence - less context breaking
|
671 |
+
if ShowButtons:
|
672 |
+
bp1,bp2 = st.columns([.5,.5])
|
673 |
+
with bp1:
|
674 |
+
if st.button(label='💾 Save Name'):
|
675 |
+
SaveFileNameClicked()
|
676 |
+
with bp2:
|
677 |
+
if st.button(label='💾 Save File'):
|
678 |
+
SaveFileTextClicked()
|
679 |
|
680 |
new_file_content_area = st.session_state['file_content_area']
|
681 |
if new_file_content_area != file_contents:
|