awacke1 commited on
Commit
c036890
β€’
1 Parent(s): 11af185

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -23
app.py CHANGED
@@ -442,7 +442,7 @@ def FileSidebar():
442
  file_name=''
443
  next_action=''
444
 
445
-
446
  for file in all_files:
447
  col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
448
  with col1:
@@ -450,74 +450,59 @@ def FileSidebar():
450
  file_contents = load_file(file)
451
  file_name=file
452
  next_action='md'
 
453
  with col2:
454
  st.markdown(get_table_download_link(file), unsafe_allow_html=True)
455
  with col3:
456
  if st.button("πŸ“‚", key="open_"+file): # open emoji button
457
  file_contents = load_file(file)
458
  file_name=file
 
459
  st.session_state['lastfilename'] = file
460
  st.session_state['filename'] = file
461
  st.session_state['filetext'] = file_contents
462
-
463
-
464
- next_action='open'
465
  with col4:
466
  if st.button("πŸ”", key="read_"+file): # search emoji button
467
  file_contents = load_file(file)
468
  file_name=file
469
  next_action='search'
 
470
  with col5:
471
  if st.button("πŸ—‘", key="delete_"+file):
472
  os.remove(file)
473
  file_name=file
474
  st.experimental_rerun()
 
 
475
 
476
 
477
  if len(file_contents) > 0:
478
- if next_action=='open':
479
-
480
- # For "open", prep session state if it hasn't been yet
481
  if 'lastfilename' not in st.session_state:
482
  st.session_state['lastfilename'] = ''
483
  if 'filename' not in st.session_state:
484
  st.session_state['filename'] = ''
485
  if 'filetext' not in st.session_state:
486
  st.session_state['filetext'] = ''
487
-
488
  open1, open2 = st.columns(spec=[.8,.2])
489
-
490
  with open1:
491
-
492
- # File Name Input
493
  file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
494
-
495
- # File Text Input
496
  file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=500)
497
-
498
  if st.button(label='πŸ’Ύ Save File Name'):
499
  SaveFileNameClicked()
500
-
501
  if st.button(label='πŸ’Ύ Save File Text'):
502
  SaveFileTextClicked()
503
-
504
-
505
  new_file_content_area = st.session_state['file_content_area']
506
  if new_file_content_area != file_contents:
507
  st.markdown(new_file_content_area) #changed
508
- #with open2:
509
-
510
 
511
-
512
- #try:
513
  if st.button("πŸ” Run AI Meta Strategy", key="filecontentssearch"):
514
  #search_glossary(file_content_area)
515
  filesearch = PromptPrefix + file_content_area
516
  st.markdown(filesearch)
517
  if st.button(key=rerun, label='πŸ”Re-Spec' ):
518
  search_glossary(filesearch)
519
- #except:
520
- #st.markdown('GPT is sleeping. Restart ETA 30 seconds.')
521
 
522
  if next_action=='md':
523
  st.markdown(file_contents)
 
442
  file_name=''
443
  next_action=''
444
 
445
+ # FileSidebar Adds files matching pattern to sidebar where we feature a 🌐View, πŸ“‚Open, πŸ”Run, and πŸ—‘Delete per file
446
  for file in all_files:
447
  col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
448
  with col1:
 
450
  file_contents = load_file(file)
451
  file_name=file
452
  next_action='md'
453
+ st.session_state['next_action'] = next_action
454
  with col2:
455
  st.markdown(get_table_download_link(file), unsafe_allow_html=True)
456
  with col3:
457
  if st.button("πŸ“‚", key="open_"+file): # open emoji button
458
  file_contents = load_file(file)
459
  file_name=file
460
+ next_action='open'
461
  st.session_state['lastfilename'] = file
462
  st.session_state['filename'] = file
463
  st.session_state['filetext'] = file_contents
464
+ st.session_state['next_action'] = next_action
 
 
465
  with col4:
466
  if st.button("πŸ”", key="read_"+file): # search emoji button
467
  file_contents = load_file(file)
468
  file_name=file
469
  next_action='search'
470
+ st.session_state['next_action'] = next_action
471
  with col5:
472
  if st.button("πŸ—‘", key="delete_"+file):
473
  os.remove(file)
474
  file_name=file
475
  st.experimental_rerun()
476
+ next_action='delete'
477
+ st.session_state['next_action'] = next_action
478
 
479
 
480
  if len(file_contents) > 0:
481
+ if next_action=='open': # For "open", prep session state if it hasn't been yet
 
 
482
  if 'lastfilename' not in st.session_state:
483
  st.session_state['lastfilename'] = ''
484
  if 'filename' not in st.session_state:
485
  st.session_state['filename'] = ''
486
  if 'filetext' not in st.session_state:
487
  st.session_state['filetext'] = ''
 
488
  open1, open2 = st.columns(spec=[.8,.2])
 
489
  with open1:
 
 
490
  file_name_input = st.text_input(key='file_name_input', on_change=SaveFileNameClicked, label="File Name:",value=file_name )
 
 
491
  file_content_area = st.text_area(key='file_content_area', on_change=SaveFileTextClicked, label="File Contents:", value=file_contents, height=500)
 
492
  if st.button(label='πŸ’Ύ Save File Name'):
493
  SaveFileNameClicked()
 
494
  if st.button(label='πŸ’Ύ Save File Text'):
495
  SaveFileTextClicked()
 
 
496
  new_file_content_area = st.session_state['file_content_area']
497
  if new_file_content_area != file_contents:
498
  st.markdown(new_file_content_area) #changed
 
 
499
 
 
 
500
  if st.button("πŸ” Run AI Meta Strategy", key="filecontentssearch"):
501
  #search_glossary(file_content_area)
502
  filesearch = PromptPrefix + file_content_area
503
  st.markdown(filesearch)
504
  if st.button(key=rerun, label='πŸ”Re-Spec' ):
505
  search_glossary(filesearch)
 
 
506
 
507
  if next_action=='md':
508
  st.markdown(file_contents)