Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
|
@@ -346,7 +346,6 @@ def process_document(action, selected_filename=None, chat_input=None, rfp_decode
|
|
| 346 |
return result, None, None, None, None
|
| 347 |
|
| 348 |
elif action == 'loe':
|
| 349 |
-
# LOE estimation implementation
|
| 350 |
if not selected_proposal_filename or selected_proposal_filename not in proposals:
|
| 351 |
logging.warning("No proposal document selected for LOE estimation.")
|
| 352 |
return "No proposal document selected for LOE estimation.", None, None, None, None
|
|
@@ -617,12 +616,7 @@ def master_callback(
|
|
| 617 |
|
| 618 |
global gemini_lock, uploaded_documents_bytes
|
| 619 |
|
| 620 |
-
|
| 621 |
-
'shred-action-btn', 'proposal-action-btn', 'compliance-action-btn',
|
| 622 |
-
'recover-action-btn', 'board-action-btn', 'loe-action-btn'
|
| 623 |
-
] and preview_window_state != "shrunk":
|
| 624 |
-
return dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, dash.no_update, "shrunk"
|
| 625 |
-
|
| 626 |
if triggered_id == 'cancel-action-btn':
|
| 627 |
output_data_upload = html.Div("[Cancelled by user]\n", style={"wordWrap": "break-word"})
|
| 628 |
doc_options = [{'label': fn, 'value': fn} for fn in uploaded_documents.keys()]
|
|
@@ -638,6 +632,7 @@ def master_callback(
|
|
| 638 |
"expanded"
|
| 639 |
)
|
| 640 |
|
|
|
|
| 641 |
if triggered_id == 'upload-document' and rfp_content is not None and rfp_filename:
|
| 642 |
content_type, content_string = rfp_content.split(',')
|
| 643 |
decoded = base64.b64decode(content_string)
|
|
@@ -670,6 +665,7 @@ def master_callback(
|
|
| 670 |
else:
|
| 671 |
logging.error(f"Failed to decode uploaded proposal: {proposal_filename}")
|
| 672 |
|
|
|
|
| 673 |
if triggered_id and isinstance(doc_delete_clicks, list):
|
| 674 |
for i, n_click in enumerate(doc_delete_clicks):
|
| 675 |
if n_click:
|
|
@@ -720,7 +716,12 @@ def master_callback(
|
|
| 720 |
|
| 721 |
output_data_upload = html.Div("No action taken yet.", style={"wordWrap": "break-word"})
|
| 722 |
|
| 723 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
got_lock = gemini_lock.acquire(blocking=False)
|
| 725 |
if not got_lock:
|
| 726 |
output_data_upload = html.Div("Another Gemini operation is in progress. Please wait or cancel.", style={"wordWrap": "break-word"})
|
|
@@ -747,33 +748,7 @@ def master_callback(
|
|
| 747 |
action_name, doc_value, chat_input, uploaded_rfp_decoded_bytes, proposal_value
|
| 748 |
)
|
| 749 |
output_data_upload = dcc.Markdown(result, style={"whiteSpace": "pre-wrap", "wordWrap": "break-word"})
|
| 750 |
-
|
| 751 |
-
gemini_lock.release()
|
| 752 |
-
doc_options = [{'label': fn, 'value': fn} for fn in uploaded_documents.keys()]
|
| 753 |
-
doc_value = doc_value if doc_value in uploaded_documents else (next(iter(uploaded_documents), None) if uploaded_documents else None)
|
| 754 |
-
proposal_options = [{'label': fn, 'value': fn} for fn in proposals.keys()]
|
| 755 |
-
proposal_value = proposal_value if proposal_value in proposals else (next(iter(proposals), None) if proposals else None)
|
| 756 |
-
documents_list = get_documents_list(uploaded_documents, shredded_documents)
|
| 757 |
-
proposals_list = get_proposals_list(proposals)
|
| 758 |
-
return (
|
| 759 |
-
output_data_upload,
|
| 760 |
-
documents_list, doc_options, doc_value,
|
| 761 |
-
proposals_list, proposal_options, proposal_value,
|
| 762 |
-
"expanded"
|
| 763 |
-
)
|
| 764 |
-
|
| 765 |
-
if triggered_id in ['proposal-action-btn', 'recover-action-btn', 'loe-action-btn']:
|
| 766 |
-
got_lock = gemini_lock.acquire(blocking=False)
|
| 767 |
-
if not got_lock:
|
| 768 |
-
output_data_upload = html.Div("Another Gemini operation is in progress. Please wait or cancel.", style={"wordWrap": "break-word"})
|
| 769 |
-
return (
|
| 770 |
-
output_data_upload,
|
| 771 |
-
documents_list, doc_options, doc_value,
|
| 772 |
-
proposals_list, proposal_options, proposal_value,
|
| 773 |
-
"expanded"
|
| 774 |
-
)
|
| 775 |
-
try:
|
| 776 |
-
if triggered_id == "proposal-action-btn":
|
| 777 |
action_name = "proposal"
|
| 778 |
selected_bytes = uploaded_documents_bytes.get(doc_value, None)
|
| 779 |
result, _, _, generated_filename, generated_docx_bytes = process_document(
|
|
@@ -804,7 +779,7 @@ def master_callback(
|
|
| 804 |
output_data_upload,
|
| 805 |
documents_list, doc_options, doc_value,
|
| 806 |
proposals_list, proposal_options, proposal_value,
|
| 807 |
-
"
|
| 808 |
)
|
| 809 |
|
| 810 |
doc_value = doc_value if doc_value in uploaded_documents else (next(iter(uploaded_documents), None) if uploaded_documents else None)
|
|
|
|
| 346 |
return result, None, None, None, None
|
| 347 |
|
| 348 |
elif action == 'loe':
|
|
|
|
| 349 |
if not selected_proposal_filename or selected_proposal_filename not in proposals:
|
| 350 |
logging.warning("No proposal document selected for LOE estimation.")
|
| 351 |
return "No proposal document selected for LOE estimation.", None, None, None, None
|
|
|
|
| 616 |
|
| 617 |
global gemini_lock, uploaded_documents_bytes
|
| 618 |
|
| 619 |
+
# Cancel action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
if triggered_id == 'cancel-action-btn':
|
| 621 |
output_data_upload = html.Div("[Cancelled by user]\n", style={"wordWrap": "break-word"})
|
| 622 |
doc_options = [{'label': fn, 'value': fn} for fn in uploaded_documents.keys()]
|
|
|
|
| 632 |
"expanded"
|
| 633 |
)
|
| 634 |
|
| 635 |
+
# Handle uploads
|
| 636 |
if triggered_id == 'upload-document' and rfp_content is not None and rfp_filename:
|
| 637 |
content_type, content_string = rfp_content.split(',')
|
| 638 |
decoded = base64.b64decode(content_string)
|
|
|
|
| 665 |
else:
|
| 666 |
logging.error(f"Failed to decode uploaded proposal: {proposal_filename}")
|
| 667 |
|
| 668 |
+
# Handle deletes
|
| 669 |
if triggered_id and isinstance(doc_delete_clicks, list):
|
| 670 |
for i, n_click in enumerate(doc_delete_clicks):
|
| 671 |
if n_click:
|
|
|
|
| 716 |
|
| 717 |
output_data_upload = html.Div("No action taken yet.", style={"wordWrap": "break-word"})
|
| 718 |
|
| 719 |
+
action_btns = [
|
| 720 |
+
'shred-action-btn', 'proposal-action-btn', 'compliance-action-btn',
|
| 721 |
+
'recover-action-btn', 'board-action-btn', 'loe-action-btn'
|
| 722 |
+
]
|
| 723 |
+
|
| 724 |
+
if triggered_id in action_btns:
|
| 725 |
got_lock = gemini_lock.acquire(blocking=False)
|
| 726 |
if not got_lock:
|
| 727 |
output_data_upload = html.Div("Another Gemini operation is in progress. Please wait or cancel.", style={"wordWrap": "break-word"})
|
|
|
|
| 748 |
action_name, doc_value, chat_input, uploaded_rfp_decoded_bytes, proposal_value
|
| 749 |
)
|
| 750 |
output_data_upload = dcc.Markdown(result, style={"whiteSpace": "pre-wrap", "wordWrap": "break-word"})
|
| 751 |
+
elif triggered_id == "proposal-action-btn":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
action_name = "proposal"
|
| 753 |
selected_bytes = uploaded_documents_bytes.get(doc_value, None)
|
| 754 |
result, _, _, generated_filename, generated_docx_bytes = process_document(
|
|
|
|
| 779 |
output_data_upload,
|
| 780 |
documents_list, doc_options, doc_value,
|
| 781 |
proposals_list, proposal_options, proposal_value,
|
| 782 |
+
"shrunk"
|
| 783 |
)
|
| 784 |
|
| 785 |
doc_value = doc_value if doc_value in uploaded_documents else (next(iter(uploaded_documents), None) if uploaded_documents else None)
|