phyloforfun commited on
Commit
ce5b499
1 Parent(s): daf2e4b

file upload gallery

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -727,7 +727,7 @@ def save_prompt_yaml(filename, col_right_save):
727
  upload_to_drive(filepath, filename)
728
 
729
  with col_right_save:
730
- create_download_button(filepath, filename)
731
 
732
  # Function to upload files to Google Drive
733
  def upload_to_drive(filepath, filename):
@@ -833,7 +833,7 @@ def upload_local_prompt_to_server(dir_prompt):
833
  else:
834
  st.error("Please upload a .yaml file that you previously created using this Prompt Builder tool.")
835
 
836
- def create_download_button(file_path, selected_yaml_file):
837
  file_label = f"Download {selected_yaml_file}"
838
  with open(file_path, 'rb') as f:
839
  st.download_button(
@@ -914,7 +914,7 @@ The desired null value is also given. Populate the field with the null value of
914
  download_file_path = os.path.join(dir_prompt, st.session_state['selected_yaml_file'] )
915
  # Create the download button
916
  st.write('##')
917
- create_download_button(download_file_path, st.session_state['selected_yaml_file'] )
918
 
919
 
920
  # Prompt Author Information
@@ -1135,13 +1135,13 @@ The desired null value is also given. Populate the field with the null value of
1135
  col_left_save, col_right_save, _ = st.columns([2,2,8])
1136
  with col_left_save:
1137
  # Input for new file name
1138
- new_filename = st.text_input("Enter filename to save your prompt as a configuration YAML:",placeholder='my_prompt_name')
1139
  # Button to save the new YAML file
1140
  if st.button('Save YAML', type='primary'):
1141
- if new_filename:
1142
  if check_unique_mapping_assignments():
1143
- if check_prompt_yaml_filename(new_filename):
1144
- save_prompt_yaml(new_filename, col_right_save)
1145
  else:
1146
  st.error("File name can only contain letters, numbers, underscores, and dashes. Cannot contain spaces.")
1147
  else:
@@ -1157,7 +1157,12 @@ The desired null value is also given. Populate the field with the null value of
1157
  st.rerun()
1158
 
1159
  with col_prompt_main_right:
1160
- st.subheader('All Prompt Components')
 
 
 
 
 
1161
  st.session_state['prompt_info'] = {
1162
  'prompt_author': st.session_state['prompt_author'],
1163
  'prompt_author_institution': st.session_state['prompt_author_institution'],
@@ -1663,6 +1668,8 @@ if 'input_list_small' not in st.session_state:
1663
  st.session_state['input_list_small'] = []
1664
  if 'selected_yaml_file' not in st.session_state:
1665
  st.session_state['selected_yaml_file'] = None
 
 
1666
 
1667
 
1668
  # if not st.session_state.private_file:
 
727
  upload_to_drive(filepath, filename)
728
 
729
  with col_right_save:
730
+ create_download_button_yaml(filepath, filename)
731
 
732
  # Function to upload files to Google Drive
733
  def upload_to_drive(filepath, filename):
 
833
  else:
834
  st.error("Please upload a .yaml file that you previously created using this Prompt Builder tool.")
835
 
836
+ def create_download_button_yaml(file_path, selected_yaml_file):
837
  file_label = f"Download {selected_yaml_file}"
838
  with open(file_path, 'rb') as f:
839
  st.download_button(
 
914
  download_file_path = os.path.join(dir_prompt, st.session_state['selected_yaml_file'] )
915
  # Create the download button
916
  st.write('##')
917
+ create_download_button_yaml(download_file_path, st.session_state['selected_yaml_file'] )
918
 
919
 
920
  # Prompt Author Information
 
1135
  col_left_save, col_right_save, _ = st.columns([2,2,8])
1136
  with col_left_save:
1137
  # Input for new file name
1138
+ st.session_state['new_prompt_yaml_filename'] = st.text_input("Enter filename to save your prompt as a configuration YAML:",placeholder='my_prompt_name')
1139
  # Button to save the new YAML file
1140
  if st.button('Save YAML', type='primary'):
1141
+ if st.session_state['new_prompt_yaml_filename']:
1142
  if check_unique_mapping_assignments():
1143
+ if check_prompt_yaml_filename(st.session_state['new_prompt_yaml_filename']):
1144
+ save_prompt_yaml(st.session_state['new_prompt_yaml_filename'], col_right_save)
1145
  else:
1146
  st.error("File name can only contain letters, numbers, underscores, and dashes. Cannot contain spaces.")
1147
  else:
 
1157
  st.rerun()
1158
 
1159
  with col_prompt_main_right:
1160
+ show_prompt_name = None
1161
+ if st.session_state['new_prompt_yaml_filename'] is not None:
1162
+ show_prompt_name = f"Will be saved as: {st.session_state['new_prompt_yaml_filename']}"
1163
+ else:
1164
+ show_prompt_name = f"Editing: {st.session_state['selected_yaml_file']}"
1165
+ st.subheader(f'Full Prompt ({show_prompt_name})')
1166
  st.session_state['prompt_info'] = {
1167
  'prompt_author': st.session_state['prompt_author'],
1168
  'prompt_author_institution': st.session_state['prompt_author_institution'],
 
1668
  st.session_state['input_list_small'] = []
1669
  if 'selected_yaml_file' not in st.session_state:
1670
  st.session_state['selected_yaml_file'] = None
1671
+ if 'new_prompt_yaml_filename' not in st.session_state:
1672
+ st.session_state['new_prompt_yaml_filename'] = None
1673
 
1674
 
1675
  # if not st.session_state.private_file: