Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import io
|
|
| 4 |
import dash
|
| 5 |
from dash import dcc, html, Input, Output, State, callback_context, ALL
|
| 6 |
import dash_bootstrap_components as dbc
|
|
|
|
| 7 |
import pandas as pd
|
| 8 |
import logging
|
| 9 |
from docx import Document
|
|
@@ -843,7 +844,32 @@ def unified_master_callback(
|
|
| 843 |
if triggered_id == "shred-action-btn":
|
| 844 |
action_name = "shred"
|
| 845 |
result, generated_filename, generated_xlsx_bytes, _, _ = process_document(sess_data, action_name, doc_value, chat_input, uploaded_rfp_decoded_bytes, None)
|
| 846 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
elif triggered_id == "compliance-action-btn":
|
| 848 |
action_name = "compliance"
|
| 849 |
result, generated_filename, generated_xlsx_bytes, _, _ = process_document(
|
|
|
|
| 4 |
import dash
|
| 5 |
from dash import dcc, html, Input, Output, State, callback_context, ALL
|
| 6 |
import dash_bootstrap_components as dbc
|
| 7 |
+
import dash.dash_table as dt
|
| 8 |
import pandas as pd
|
| 9 |
import logging
|
| 10 |
from docx import Document
|
|
|
|
| 844 |
if triggered_id == "shred-action-btn":
|
| 845 |
action_name = "shred"
|
| 846 |
result, generated_filename, generated_xlsx_bytes, _, _ = process_document(sess_data, action_name, doc_value, chat_input, uploaded_rfp_decoded_bytes, None)
|
| 847 |
+
# Try to parse as markdown table, show DataTable if possible, else fallback to Markdown
|
| 848 |
+
try:
|
| 849 |
+
df = parse_markdown_table(result)
|
| 850 |
+
output_data_upload = dt.DataTable(
|
| 851 |
+
columns=[{"name": i, "id": i} for i in df.columns],
|
| 852 |
+
data=df.to_dict('records'),
|
| 853 |
+
style_table={
|
| 854 |
+
"overflowX": "auto",
|
| 855 |
+
"overflowY": "auto",
|
| 856 |
+
"maxHeight": "60vh",
|
| 857 |
+
"minWidth": "100%"
|
| 858 |
+
},
|
| 859 |
+
style_cell={
|
| 860 |
+
"whiteSpace": "normal",
|
| 861 |
+
"height": "auto",
|
| 862 |
+
"textAlign": "left",
|
| 863 |
+
"wordBreak": "break-word"
|
| 864 |
+
},
|
| 865 |
+
style_header={
|
| 866 |
+
"fontWeight": "bold"
|
| 867 |
+
},
|
| 868 |
+
page_action="none"
|
| 869 |
+
)
|
| 870 |
+
except Exception as e:
|
| 871 |
+
logging.warning(f"Failed to parse markdown as table for preview: {e}")
|
| 872 |
+
output_data_upload = dcc.Markdown(result, style={"whiteSpace": "pre-wrap", "wordWrap": "break-word"})
|
| 873 |
elif triggered_id == "compliance-action-btn":
|
| 874 |
action_name = "compliance"
|
| 875 |
result, generated_filename, generated_xlsx_bytes, _, _ = process_document(
|