Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -289,6 +289,7 @@ def remove_file(n_clicks, existing_files):
|
|
289 |
def generate_any_doc(n_clicks_list, btn_ids, radio_values, upload_contents, upload_filenames):
|
290 |
global current_document, document_type, shredded_document, pink_review_document
|
291 |
ctx = callback_context
|
|
|
292 |
if not ctx.triggered:
|
293 |
raise dash.exceptions.PreventUpdate
|
294 |
idx = [i for i, x in enumerate(n_clicks_list) if x]
|
@@ -299,6 +300,7 @@ def generate_any_doc(n_clicks_list, btn_ids, radio_values, upload_contents, uplo
|
|
299 |
document_type = doc_type
|
300 |
|
301 |
if not uploaded_files and doc_type == "Shred":
|
|
|
302 |
return html.Div("Please upload a document before shredding."), ""
|
303 |
|
304 |
source = radio_values[idx] if radio_values and len(radio_values) > idx else 'loaded'
|
@@ -306,6 +308,7 @@ def generate_any_doc(n_clicks_list, btn_ids, radio_values, upload_contents, uplo
|
|
306 |
|
307 |
if doc_type == "Shred":
|
308 |
file_contents = list(uploaded_files.values())
|
|
|
309 |
try:
|
310 |
generated = generate_document(doc_type, file_contents)
|
311 |
current_document = generated
|
@@ -318,12 +321,14 @@ def generate_any_doc(n_clicks_list, btn_ids, radio_values, upload_contents, uplo
|
|
318 |
return html.Div(f"Error generating document: {str(e)}"), "Error"
|
319 |
|
320 |
if shredded_document is None:
|
|
|
321 |
return html.Div("Please shred a document first."), ""
|
322 |
|
323 |
if source == 'uploaded':
|
324 |
if upload_contents and len(upload_contents) > idx and upload_contents[idx] and upload_filenames and len(upload_filenames) > idx and upload_filenames[idx]:
|
325 |
doc_content = process_document(upload_contents[idx], upload_filenames[idx])
|
326 |
else:
|
|
|
327 |
return html.Div("Please upload a document to use as source."), ""
|
328 |
else:
|
329 |
if doc_type == "Pink":
|
|
|
289 |
def generate_any_doc(n_clicks_list, btn_ids, radio_values, upload_contents, upload_filenames):
|
290 |
global current_document, document_type, shredded_document, pink_review_document
|
291 |
ctx = callback_context
|
292 |
+
logging.info(f"generate_any_doc triggered: n_clicks_list={n_clicks_list}, btn_ids={btn_ids}")
|
293 |
if not ctx.triggered:
|
294 |
raise dash.exceptions.PreventUpdate
|
295 |
idx = [i for i, x in enumerate(n_clicks_list) if x]
|
|
|
300 |
document_type = doc_type
|
301 |
|
302 |
if not uploaded_files and doc_type == "Shred":
|
303 |
+
logging.info("No uploaded files for Shred. Aborting.")
|
304 |
return html.Div("Please upload a document before shredding."), ""
|
305 |
|
306 |
source = radio_values[idx] if radio_values and len(radio_values) > idx else 'loaded'
|
|
|
308 |
|
309 |
if doc_type == "Shred":
|
310 |
file_contents = list(uploaded_files.values())
|
311 |
+
logging.info(f"Calling OpenAI for Shred with {len(file_contents)} files.")
|
312 |
try:
|
313 |
generated = generate_document(doc_type, file_contents)
|
314 |
current_document = generated
|
|
|
321 |
return html.Div(f"Error generating document: {str(e)}"), "Error"
|
322 |
|
323 |
if shredded_document is None:
|
324 |
+
logging.info("Shredded document is None. Aborting.")
|
325 |
return html.Div("Please shred a document first."), ""
|
326 |
|
327 |
if source == 'uploaded':
|
328 |
if upload_contents and len(upload_contents) > idx and upload_contents[idx] and upload_filenames and len(upload_filenames) > idx and upload_filenames[idx]:
|
329 |
doc_content = process_document(upload_contents[idx], upload_filenames[idx])
|
330 |
else:
|
331 |
+
logging.info("No uploaded doc content for this doc type. Aborting.")
|
332 |
return html.Div("Please upload a document to use as source."), ""
|
333 |
else:
|
334 |
if doc_type == "Pink":
|