Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,6 +69,38 @@ with st.expander("Help / About 📚", expanded=False):
|
|
| 69 |
|
| 70 |
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
def FileSidebar():
|
| 73 |
# ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
|
| 74 |
# Compose a file sidebar of markdown md files:
|
|
@@ -816,35 +848,6 @@ def truncate_document(document, length):
|
|
| 816 |
def divide_document(document, max_length):
|
| 817 |
return [document[i:i+max_length] for i in range(0, len(document), max_length)]
|
| 818 |
|
| 819 |
-
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|
| 820 |
-
@st.cache_resource
|
| 821 |
-
def get_table_download_link(file_path):
|
| 822 |
-
with open(file_path, 'r') as file:
|
| 823 |
-
data = file.read()
|
| 824 |
-
|
| 825 |
-
b64 = base64.b64encode(data.encode()).decode()
|
| 826 |
-
file_name = os.path.basename(file_path)
|
| 827 |
-
ext = os.path.splitext(file_name)[1] # get the file extension
|
| 828 |
-
if ext == '.txt':
|
| 829 |
-
mime_type = 'text/plain'
|
| 830 |
-
elif ext == '.py':
|
| 831 |
-
mime_type = 'text/plain'
|
| 832 |
-
elif ext == '.xlsx':
|
| 833 |
-
mime_type = 'text/plain'
|
| 834 |
-
elif ext == '.csv':
|
| 835 |
-
mime_type = 'text/plain'
|
| 836 |
-
elif ext == '.htm':
|
| 837 |
-
mime_type = 'text/html'
|
| 838 |
-
elif ext == '.md':
|
| 839 |
-
mime_type = 'text/markdown'
|
| 840 |
-
elif ext == '.wav':
|
| 841 |
-
mime_type = 'audio/wav'
|
| 842 |
-
else:
|
| 843 |
-
mime_type = 'application/octet-stream' # general binary data type
|
| 844 |
-
href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
|
| 845 |
-
return href
|
| 846 |
-
|
| 847 |
-
|
| 848 |
def CompressXML(xml_text):
|
| 849 |
root = ET.fromstring(xml_text)
|
| 850 |
for elem in list(root.iter()):
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
+
|
| 73 |
+
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|
| 74 |
+
@st.cache_resource
|
| 75 |
+
def get_table_download_link(file_path):
|
| 76 |
+
with open(file_path, 'r') as file:
|
| 77 |
+
data = file.read()
|
| 78 |
+
|
| 79 |
+
b64 = base64.b64encode(data.encode()).decode()
|
| 80 |
+
file_name = os.path.basename(file_path)
|
| 81 |
+
ext = os.path.splitext(file_name)[1] # get the file extension
|
| 82 |
+
if ext == '.txt':
|
| 83 |
+
mime_type = 'text/plain'
|
| 84 |
+
elif ext == '.py':
|
| 85 |
+
mime_type = 'text/plain'
|
| 86 |
+
elif ext == '.xlsx':
|
| 87 |
+
mime_type = 'text/plain'
|
| 88 |
+
elif ext == '.csv':
|
| 89 |
+
mime_type = 'text/plain'
|
| 90 |
+
elif ext == '.htm':
|
| 91 |
+
mime_type = 'text/html'
|
| 92 |
+
elif ext == '.md':
|
| 93 |
+
mime_type = 'text/markdown'
|
| 94 |
+
elif ext == '.wav':
|
| 95 |
+
mime_type = 'audio/wav'
|
| 96 |
+
else:
|
| 97 |
+
mime_type = 'application/octet-stream' # general binary data type
|
| 98 |
+
href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
|
| 99 |
+
return href
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
def FileSidebar():
|
| 105 |
# ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
|
| 106 |
# Compose a file sidebar of markdown md files:
|
|
|
|
| 848 |
def divide_document(document, max_length):
|
| 849 |
return [document[i:i+max_length] for i in range(0, len(document), max_length)]
|
| 850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
def CompressXML(xml_text):
|
| 852 |
root = ET.fromstring(xml_text)
|
| 853 |
for elem in list(root.iter()):
|