bluenevus commited on
Commit
5931476
·
verified ·
1 Parent(s): 9e26678

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -188,9 +188,11 @@ def remove_file(n_clicks, existing_files):
188
  if not ctx.triggered:
189
  raise dash.exceptions.PreventUpdate
190
  removed_file = ctx.triggered[0]['prop_id'].split(',')[0].split(':')[-1].strip('}')
191
- uploaded_files.pop(removed_file, None)
192
- shredded_document = None # Reset shredded document when a file is removed
193
- return [file for file in existing_files if file['props']['children'][1]['props']['children'] != removed_file], "Document removed. Please upload a document and click 'Shred' to begin."
 
 
194
 
195
  def generate_document(document_type, file_contents):
196
  prompt = f"""Generate a {document_type} based on the following project artifacts:
@@ -226,7 +228,6 @@ Now, generate the {document_type}:
226
  response = model.generate_content(prompt)
227
  return response.text
228
 
229
-
230
  @app.callback(
231
  Output('document-preview', 'children'),
232
  Output('loading-output', 'children'),
@@ -253,11 +254,11 @@ def generate_document_preview(*args):
253
  if triggered_id.startswith('btn-'):
254
  document_type = triggered_id.replace('btn-', '').replace('-', ' ').title()
255
  if document_type == "Shred":
256
- return html.Div("Ready to shred. Click 'Generate Document' to proceed."), "", "Ready to shred.", {'display': 'none'}, {'display': 'none'}, {'display': 'block'}
257
  elif document_type in ["Pink", "Red", "Gold"]:
258
- return html.Div(f"Ready to generate {document_type} document."), "", f"Ready to generate {document_type} document.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
259
  elif document_type in ["Pink Review", "Red Review", "Gold Review", "Virtual Board", "Loe"]:
260
- return html.Div(f"Ready to generate {document_type}."), "", f"Ready to generate {document_type}.", {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
261
  return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update
262
 
263
  if triggered_id == 'btn-generate-document':
 
188
  if not ctx.triggered:
189
  raise dash.exceptions.PreventUpdate
190
  removed_file = ctx.triggered[0]['prop_id'].split(',')[0].split(':')[-1].strip('}')
191
+ if removed_file in uploaded_files:
192
+ uploaded_files.pop(removed_file, None)
193
+ shredded_document = None # Reset shredded document when a file is removed
194
+ return [file for file in existing_files if file['props']['children'][1]['props']['children'] != removed_file], f"Document '{removed_file}' removed."
195
+ return dash.no_update, dash.no_update
196
 
197
  def generate_document(document_type, file_contents):
198
  prompt = f"""Generate a {document_type} based on the following project artifacts:
 
228
  response = model.generate_content(prompt)
229
  return response.text
230
 
 
231
  @app.callback(
232
  Output('document-preview', 'children'),
233
  Output('loading-output', 'children'),
 
254
  if triggered_id.startswith('btn-'):
255
  document_type = triggered_id.replace('btn-', '').replace('-', ' ').title()
256
  if document_type == "Shred":
257
+ return html.Div("Ready to shred. Click 'Generate Document' to proceed."), "", dash.no_update, {'display': 'none'}, {'display': 'none'}, {'display': 'block'}
258
  elif document_type in ["Pink", "Red", "Gold"]:
259
+ return html.Div(f"Ready to generate {document_type} document."), "", dash.no_update, {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
260
  elif document_type in ["Pink Review", "Red Review", "Gold Review", "Virtual Board", "Loe"]:
261
+ return html.Div(f"Ready to generate {document_type}."), "", dash.no_update, {'display': 'block'}, {'display': 'flex'}, {'display': 'block'}
262
  return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update
263
 
264
  if triggered_id == 'btn-generate-document':