Update app.py
Browse files
app.py
CHANGED
|
@@ -88,10 +88,11 @@ app.layout = dbc.Container([
|
|
| 88 |
], width=3),
|
| 89 |
dbc.Col([
|
| 90 |
html.Div(style={"height": "20px"}), # Small gap
|
|
|
|
| 91 |
dcc.Loading(
|
| 92 |
id="loading-indicator",
|
| 93 |
type="dot",
|
| 94 |
-
children=[html.Div(
|
| 95 |
),
|
| 96 |
html.Div(id='matrix-preview', className="border p-3 mb-3"),
|
| 97 |
dbc.Button("Download Matrix", id="btn-download", color="success", className="mt-3"),
|
|
@@ -213,24 +214,26 @@ Now, generate the {matrix_type}:
|
|
| 213 |
@app.callback(
|
| 214 |
Output('matrix-preview', 'children'),
|
| 215 |
Output('loading-output', 'children'),
|
| 216 |
-
|
|
|
|
| 217 |
prevent_initial_call=True
|
| 218 |
)
|
| 219 |
-
def generate_matrix(
|
| 220 |
global current_matrix, matrix_type
|
| 221 |
ctx = dash.callback_context
|
| 222 |
if not ctx.triggered:
|
| 223 |
raise PreventUpdate
|
| 224 |
-
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
| 225 |
-
matrix_type = button_id.replace('btn-', '').replace('-', ' ').title()
|
| 226 |
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
| 228 |
return html.Div("Please upload project artifacts before generating a matrix."), ""
|
| 229 |
|
| 230 |
-
|
| 231 |
|
| 232 |
try:
|
| 233 |
-
current_matrix = generate_matrix_with_gpt(matrix_type,
|
| 234 |
return dbc.Table.from_dataframe(current_matrix, striped=True, bordered=True, hover=True), f"{matrix_type} generated"
|
| 235 |
except Exception as e:
|
| 236 |
print(f"Error generating matrix: {str(e)}")
|
|
|
|
| 88 |
], width=3),
|
| 89 |
dbc.Col([
|
| 90 |
html.Div(style={"height": "20px"}), # Small gap
|
| 91 |
+
html.Div(id="loading-output"), # Text status box
|
| 92 |
dcc.Loading(
|
| 93 |
id="loading-indicator",
|
| 94 |
type="dot",
|
| 95 |
+
children=[html.Div()] # Empty div for the blinking dots
|
| 96 |
),
|
| 97 |
html.Div(id='matrix-preview', className="border p-3 mb-3"),
|
| 98 |
dbc.Button("Download Matrix", id="btn-download", color="success", className="mt-3"),
|
|
|
|
| 214 |
@app.callback(
|
| 215 |
Output('matrix-preview', 'children'),
|
| 216 |
Output('loading-output', 'children'),
|
| 217 |
+
Input({'type': 'matrix-button', 'index': dash.ALL}, 'n_clicks'),
|
| 218 |
+
State('uploaded-files-state', 'children'),
|
| 219 |
prevent_initial_call=True
|
| 220 |
)
|
| 221 |
+
def generate_matrix(n_clicks, uploaded_files_json):
|
| 222 |
global current_matrix, matrix_type
|
| 223 |
ctx = dash.callback_context
|
| 224 |
if not ctx.triggered:
|
| 225 |
raise PreventUpdate
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
button_id = ctx.triggered[0]['prop_id']
|
| 228 |
+
matrix_type = json.loads(button_id.split('.')[0])['index']
|
| 229 |
+
|
| 230 |
+
if not uploaded_files_json:
|
| 231 |
return html.Div("Please upload project artifacts before generating a matrix."), ""
|
| 232 |
|
| 233 |
+
uploaded_files = json.loads(uploaded_files_json)
|
| 234 |
|
| 235 |
try:
|
| 236 |
+
current_matrix = generate_matrix_with_gpt(matrix_type, uploaded_files)
|
| 237 |
return dbc.Table.from_dataframe(current_matrix, striped=True, bordered=True, hover=True), f"{matrix_type} generated"
|
| 238 |
except Exception as e:
|
| 239 |
print(f"Error generating matrix: {str(e)}")
|