Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -213,29 +213,39 @@ def main():
|
|
213 |
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
214 |
|
215 |
# sidebar of files
|
|
|
|
|
216 |
for file in all_files:
|
217 |
-
|
218 |
-
col1, col2, col3 = st.sidebar.columns([5,1,1]) # adjust the ratio as needed
|
219 |
with col1:
|
220 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
221 |
with col2:
|
222 |
if st.button("π", key="read_"+file): # search emoji button
|
223 |
with open(file, 'r') as f:
|
224 |
file_contents = f.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
with col3:
|
226 |
if st.button("π", key="delete_"+file):
|
227 |
os.remove(file)
|
228 |
st.experimental_rerun()
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
239 |
|
240 |
if __name__ == "__main__":
|
241 |
main()
|
|
|
213 |
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
214 |
|
215 |
# sidebar of files
|
216 |
+
file_contents=''
|
217 |
+
next_action=''
|
218 |
for file in all_files:
|
219 |
+
col1, col2, col3, col4 = st.sidebar.columns([5,1,1,1]) # adjust the ratio as needed
|
|
|
220 |
with col1:
|
221 |
st.markdown(get_table_download_link(file), unsafe_allow_html=True)
|
222 |
with col2:
|
223 |
if st.button("π", key="read_"+file): # search emoji button
|
224 |
with open(file, 'r') as f:
|
225 |
file_contents = f.read()
|
226 |
+
next_action='search'
|
227 |
+
with col2:
|
228 |
+
if st.button("π", key="open_"+file): # open emoji button
|
229 |
+
with open(file, 'r') as f:
|
230 |
+
file_contents = f.read()
|
231 |
+
next_action='open'
|
232 |
with col3:
|
233 |
if st.button("π", key="delete_"+file):
|
234 |
os.remove(file)
|
235 |
st.experimental_rerun()
|
236 |
+
|
237 |
+
if len(file_contents) > 0:
|
238 |
+
if next_action=='open':
|
239 |
+
file_content_area = st.text_area("File Contents:", file_contents, height=500)
|
240 |
+
if next_action=='search':
|
241 |
+
#if st.button('π¬ Chat with file'):
|
242 |
+
st.write('Reasoning with your inputs...')
|
243 |
+
response = chat_with_file_contents(file_content_area)
|
244 |
+
st.write('Response:')
|
245 |
+
st.write(response)
|
246 |
+
filename = generate_filename(file_content_area, choice)
|
247 |
+
create_file(filename, file_content_area, response)
|
248 |
+
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
249 |
|
250 |
if __name__ == "__main__":
|
251 |
main()
|