Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
|
@@ -96,13 +96,7 @@ def process_document(action, selected_filename=None, chat_input=None, selected_p
|
|
| 96 |
else:
|
| 97 |
doc_content = None
|
| 98 |
elif action == "proposal":
|
| 99 |
-
|
| 100 |
-
doc_content = uploaded_proposals[selected_proposal]
|
| 101 |
-
elif uploaded_proposals:
|
| 102 |
-
doc_content = next(iter(uploaded_proposals.values()))
|
| 103 |
-
selected_proposal = next(iter(uploaded_proposals.keys()))
|
| 104 |
-
else:
|
| 105 |
-
doc_content = None
|
| 106 |
|
| 107 |
if action == 'shred':
|
| 108 |
if not doc_content:
|
|
@@ -373,7 +367,7 @@ app.layout = dbc.Container([
|
|
| 373 |
]),
|
| 374 |
html.Div([
|
| 375 |
dbc.Button("Shred", id="shred-action-btn", className="me-3 mb-2 btn-primary"),
|
| 376 |
-
dbc.Button("Proposal", id="
|
| 377 |
dbc.Button("Compliance", id="compliance-action-btn", className="me-3 mb-2 btn-tertiary"),
|
| 378 |
dbc.Button("Recover", id="recover-action-btn", className="me-3 mb-2 btn-tertiary"),
|
| 379 |
dbc.Button("Virtual Board", id="board-action-btn", className="me-3 mb-2 btn-tertiary"),
|
|
@@ -415,7 +409,7 @@ app.layout = dbc.Container([
|
|
| 415 |
State('select-generated-dropdown', 'value'),
|
| 416 |
State('select-generated-dropdown', 'options'),
|
| 417 |
Input('shred-action-btn', 'n_clicks'),
|
| 418 |
-
Input('
|
| 419 |
Input('compliance-action-btn', 'n_clicks'),
|
| 420 |
Input('recover-action-btn', 'n_clicks'),
|
| 421 |
Input('board-action-btn', 'n_clicks'),
|
|
@@ -432,7 +426,7 @@ def master_callback(
|
|
| 432 |
rfp_content, rfp_filename, rfp_delete_clicks, selected_doc,
|
| 433 |
proposal_content, proposal_filename, proposal_delete_clicks, selected_proposal,
|
| 434 |
generated_delete_clicks, selected_generated, generated_options,
|
| 435 |
-
shred_clicks,
|
| 436 |
selected_generated_dropdown,
|
| 437 |
chat_input, selected_filename, selected_proposal_dropdown, selected_generated_dropdown_state
|
| 438 |
):
|
|
@@ -516,13 +510,13 @@ def master_callback(
|
|
| 516 |
output_data_upload = html.Div("No action taken yet.", style={"wordWrap": "break-word"})
|
| 517 |
|
| 518 |
action_buttons = [
|
| 519 |
-
'shred-action-btn', '
|
| 520 |
'recover-action-btn', 'board-action-btn', 'loe-action-btn'
|
| 521 |
]
|
| 522 |
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
return (
|
| 527 |
uploaded_doc_list,
|
| 528 |
doc_options,
|
|
@@ -549,9 +543,14 @@ def master_callback(
|
|
| 549 |
logging.info(f"Generated docx saved: {generated_docx_name}")
|
| 550 |
new_selected_generated = generated_docx_name
|
| 551 |
|
| 552 |
-
elif triggered_id == '
|
| 553 |
-
|
| 554 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
if generated_docx_bytes and generated_docx_name:
|
| 556 |
generated_documents[generated_docx_name] = generated_docx_bytes
|
| 557 |
logging.info(f"Generated proposal docx saved: {generated_docx_name}")
|
|
|
|
| 96 |
else:
|
| 97 |
doc_content = None
|
| 98 |
elif action == "proposal":
|
| 99 |
+
pass # handled below
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
if action == 'shred':
|
| 102 |
if not doc_content:
|
|
|
|
| 367 |
]),
|
| 368 |
html.Div([
|
| 369 |
dbc.Button("Shred", id="shred-action-btn", className="me-3 mb-2 btn-primary"),
|
| 370 |
+
dbc.Button("Proposal", id="proposal-action-btn", className="me-3 mb-2 btn-secondary"),
|
| 371 |
dbc.Button("Compliance", id="compliance-action-btn", className="me-3 mb-2 btn-tertiary"),
|
| 372 |
dbc.Button("Recover", id="recover-action-btn", className="me-3 mb-2 btn-tertiary"),
|
| 373 |
dbc.Button("Virtual Board", id="board-action-btn", className="me-3 mb-2 btn-tertiary"),
|
|
|
|
| 409 |
State('select-generated-dropdown', 'value'),
|
| 410 |
State('select-generated-dropdown', 'options'),
|
| 411 |
Input('shred-action-btn', 'n_clicks'),
|
| 412 |
+
Input('proposal-action-btn', 'n_clicks'),
|
| 413 |
Input('compliance-action-btn', 'n_clicks'),
|
| 414 |
Input('recover-action-btn', 'n_clicks'),
|
| 415 |
Input('board-action-btn', 'n_clicks'),
|
|
|
|
| 426 |
rfp_content, rfp_filename, rfp_delete_clicks, selected_doc,
|
| 427 |
proposal_content, proposal_filename, proposal_delete_clicks, selected_proposal,
|
| 428 |
generated_delete_clicks, selected_generated, generated_options,
|
| 429 |
+
shred_clicks, proposal_clicks, compliance_clicks, recover_clicks, board_clicks, loe_clicks,
|
| 430 |
selected_generated_dropdown,
|
| 431 |
chat_input, selected_filename, selected_proposal_dropdown, selected_generated_dropdown_state
|
| 432 |
):
|
|
|
|
| 510 |
output_data_upload = html.Div("No action taken yet.", style={"wordWrap": "break-word"})
|
| 511 |
|
| 512 |
action_buttons = [
|
| 513 |
+
'shred-action-btn', 'proposal-action-btn', 'compliance-action-btn',
|
| 514 |
'recover-action-btn', 'board-action-btn', 'loe-action-btn'
|
| 515 |
]
|
| 516 |
|
| 517 |
+
if triggered_id == 'proposal-action-btn':
|
| 518 |
+
output_data_upload = html.Div("Generating proposal from selected documents...", style={"wordWrap": "break-word"})
|
| 519 |
+
# This is a progress placeholder, real work will happen in the next callback (Dash pattern)
|
| 520 |
return (
|
| 521 |
uploaded_doc_list,
|
| 522 |
doc_options,
|
|
|
|
| 543 |
logging.info(f"Generated docx saved: {generated_docx_name}")
|
| 544 |
new_selected_generated = generated_docx_name
|
| 545 |
|
| 546 |
+
elif triggered_id == 'proposal-action-btn':
|
| 547 |
+
result, generated_docx_bytes, generated_docx_name = process_document(
|
| 548 |
+
'proposal',
|
| 549 |
+
selected_filename,
|
| 550 |
+
chat_input,
|
| 551 |
+
None,
|
| 552 |
+
selected_generated_dropdown_state
|
| 553 |
+
)
|
| 554 |
if generated_docx_bytes and generated_docx_name:
|
| 555 |
generated_documents[generated_docx_name] = generated_docx_bytes
|
| 556 |
logging.info(f"Generated proposal docx saved: {generated_docx_name}")
|