bluenevus commited on
Commit
d96a160
·
verified ·
1 Parent(s): 38f2b04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +132 -19
app.py CHANGED
@@ -110,17 +110,54 @@ def generate_red_document(document: str, compliance_report: str) -> str:
110
  {compliance_report}
111
 
112
  Generate a revised "Red Team" document that addresses all issues found in the compliance report.
113
- Ensure that the new document:
114
- 1. Responds to all requirements with sufficient detail
115
- 2. Explains how MicroHealth will implement solutions
116
- 3. Incorporates best industry practices
117
- 4. Includes measurable outcomes for each requirement
 
 
118
 
119
- Provide the revised document in a clear, structured format.
 
 
120
  """
121
  response = model.generate_content(prompt)
122
  return response.text
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  # Layout
125
  app.layout = dbc.Container([
126
  html.H1("MicroHealth PWS Analysis and Response Generator", className="my-4"),
@@ -224,6 +261,33 @@ app.layout = dbc.Container([
224
  dbc.Button("Download R.Review Report", id="download-r-review", className="mt-3"),
225
  dcc.Download(id="download-r-review-doc")
226
  ]),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  ], id="tabs", active_tab="shred"),
228
  ])
229
 
@@ -262,20 +326,57 @@ def update_pink_output(n_clicks, shred_output, instructions):
262
  State('pink-output', 'children'),
263
  State('shred-output', 'children')
264
  )
265
- def update_p_review_output(n_clicks, contents, filename, pink_doc, requirements):
 
 
 
 
 
 
 
 
266
  if n_clicks is None:
267
  return "Click 'Evaluate Compliance' to begin."
268
 
269
- if contents:
270
- document = process_document(contents, filename)
271
- elif pink_doc:
272
- document = pink_doc
273
- else:
274
- return "Please upload a document or generate a Pink Team document first."
275
 
 
276
  compliance_report = evaluate_compliance(document, requirements)
277
  return dcc.Markdown(compliance_report)
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  @app.callback(
280
  Output('red-output', 'children'),
281
  Input('generate-red', 'n_clicks'),
@@ -364,15 +465,27 @@ def download_red(n_clicks, red_output):
364
  return dict(content=red_output, filename="red_team_document.md")
365
 
366
  @app.callback(
367
- Output("download-r-review-doc", "data"),
368
- Input("download-r-review", "n_clicks"),
369
- State('r-review-output', 'children'),
 
 
 
 
 
 
 
 
 
 
 
370
  prevent_initial_call=True,
371
  )
372
- def download_r_review(n_clicks, r_review_output):
373
- if r_review_output is None:
374
  return dash.no_update
375
- return dict(content=r_review_output, filename="r_review_report.md")
 
376
 
377
  if __name__ == '__main__':
378
  print("Starting the Dash application...")
 
110
  {compliance_report}
111
 
112
  Generate a revised "Red Team" document that addresses all issues found in the compliance report.
113
+ Follow these guidelines:
114
+ 1. Use Wikipedia style writing with active voice. Be firm with the approach, no soft words like could be, may be, should, might. Use definitve language.
115
+ 2. For each requirement, describe in detail how MicroHealth will innovate to address it.
116
+ 3. Explain the industry best practices that will be applied and the workflow to accomplish the steps in the best practice to address the requirement.
117
+ 4. Provide measurable outcomes for the customer.
118
+ 5. Limit the use of bullet points and write predominantly in paragraph format.
119
+ 6. Ensure a logical flow of steps taken by MicroHealth for each requirement.
120
 
121
+ Provide the revised document in a clear, structured format using paragraphs.
122
+ Limit the use of bullet points and write predominantly in paragraph format.
123
+ Ensure a logical flow of steps taken by MicroHealth for each requirement.
124
  """
125
  response = model.generate_content(prompt)
126
  return response.text
127
 
128
+ def generate_loe(document: str) -> Tuple[str, pd.DataFrame]:
129
+ prompt = f"""
130
+ Analyze the following document and provide a Level of Effort (LOE) breakdown:
131
+
132
+ Document:
133
+ {document}
134
+
135
+ For each section header in the document:
136
+ 1. Identify the tasks to be completed
137
+ 2. Determine the appropriate labor categories for each task
138
+ 3. Estimate the number of hours required for each labor category to complete the task
139
+
140
+ Provide a detailed breakdown and then summarize the information in a tabular format with the following columns:
141
+ - Task Summary
142
+ - Labor Categories
143
+ - Hours per Labor Category
144
+ - Total Hours
145
+
146
+ Present the detailed breakdown first, followed by the summary table.
147
+ """
148
+ response = model.generate_content(prompt)
149
+
150
+ # Extract the table from the response
151
+ table_start = response.text.find("| Task Summary |")
152
+ table_end = response.text.find("\n\n", table_start)
153
+ table_text = response.text[table_start:table_end]
154
+
155
+ # Convert the table to a pandas DataFrame
156
+ df = pd.read_csv(io.StringIO(table_text), sep='|', skipinitialspace=True).dropna(axis=1, how='all')
157
+ df.columns = df.columns.str.strip()
158
+
159
+ return response.text, df
160
+
161
  # Layout
162
  app.layout = dbc.Container([
163
  html.H1("MicroHealth PWS Analysis and Response Generator", className="my-4"),
 
261
  dbc.Button("Download R.Review Report", id="download-r-review", className="mt-3"),
262
  dcc.Download(id="download-r-review-doc")
263
  ]),
264
+ dbc.Tab(label="G.Review", tab_id="g-review", children=[
265
+ dcc.Upload(
266
+ id='upload-g-review',
267
+ children=html.Div(['Drag and Drop or ', html.A('Select Files')]),
268
+ style={
269
+ 'width': '100%',
270
+ 'height': '60px',
271
+ 'lineHeight': '60px',
272
+ 'borderWidth': '1px',
273
+ 'borderStyle': 'dashed',
274
+ 'borderRadius': '5px',
275
+ 'textAlign': 'center',
276
+ 'margin': '10px'
277
+ },
278
+ multiple=False
279
+ ),
280
+ dbc.Button("Evaluate Compliance", id="evaluate-g-review", className="mt-3"),
281
+ dbc.Spinner(html.Div(id='g-review-output')),
282
+ dbc.Button("Download G.Review Report", id="download-g-review", className="mt-3"),
283
+ dcc.Download(id="download-g-review-doc")
284
+ ]),
285
+ dbc.Tab(label="LOE", tab_id="loe", children=[
286
+ dbc.Button("Generate LOE", id="generate-loe", className="mt-3"),
287
+ dbc.Spinner(html.Div(id='loe-output')),
288
+ dbc.Button("Download LOE Report", id="download-loe", className="mt-3"),
289
+ dcc.Download(id="download-loe-doc")
290
+ ]),
291
  ], id="tabs", active_tab="shred"),
292
  ])
293
 
 
326
  State('pink-output', 'children'),
327
  State('shred-output', 'children')
328
  )
329
+
330
+ @app.callback(
331
+ Output('g-review-output', 'children'),
332
+ Input('evaluate-g-review', 'n_clicks'),
333
+ State('upload-g-review', 'contents'),
334
+ State('upload-g-review', 'filename'),
335
+ State('shred-output', 'children')
336
+ )
337
+ def update_g_review_output(n_clicks, contents, filename, requirements):
338
  if n_clicks is None:
339
  return "Click 'Evaluate Compliance' to begin."
340
 
341
+ if contents is None:
342
+ return "Please upload a document first."
 
 
 
 
343
 
344
+ document = process_document(contents, filename)
345
  compliance_report = evaluate_compliance(document, requirements)
346
  return dcc.Markdown(compliance_report)
347
 
348
+ @app.callback(
349
+ Output('loe-output', 'children'),
350
+ Input('generate-loe', 'n_clicks'),
351
+ State('shred-output', 'children')
352
+ )
353
+ def update_loe_output(n_clicks, shred_output):
354
+ if n_clicks is None:
355
+ return "Click 'Generate LOE' to begin."
356
+
357
+ if shred_output is None:
358
+ return "Please complete the Shred tab first."
359
+
360
+ loe_text, loe_df = generate_loe(shred_output)
361
+
362
+ return [
363
+ dcc.Markdown(loe_text),
364
+ dash_table.DataTable(
365
+ data=loe_df.to_dict('records'),
366
+ columns=[{'name': i, 'id': i} for i in loe_df.columns],
367
+ style_table={'overflowX': 'auto'},
368
+ style_cell={'textAlign': 'left', 'padding': '5px'},
369
+ style_header={'backgroundColor': 'rgb(230, 230, 230)', 'fontWeight': 'bold'}
370
+ )
371
+ ]
372
+
373
+ @app.callback(
374
+ [Output(f"tab-{tab}", "disabled") for tab in ["pink", "p-review", "red", "r-review", "g-review", "loe"]],
375
+ Input('shred-output', 'children')
376
+ )
377
+ def update_tab_status(shred_output):
378
+ return [shred_output is None] * 6
379
+
380
  @app.callback(
381
  Output('red-output', 'children'),
382
  Input('generate-red', 'n_clicks'),
 
465
  return dict(content=red_output, filename="red_team_document.md")
466
 
467
  @app.callback(
468
+ Output("download-g-review-doc", "data"),
469
+ Input("download-g-review", "n_clicks"),
470
+ State('g-review-output', 'children'),
471
+ prevent_initial_call=True,
472
+ )
473
+ def download_g_review(n_clicks, g_review_output):
474
+ if g_review_output is None:
475
+ return dash.no_update
476
+ return dict(content=g_review_output, filename="g_review_report.md")
477
+
478
+ @app.callback(
479
+ Output("download-loe-doc", "data"),
480
+ Input("download-loe", "n_clicks"),
481
+ State('loe-output', 'children'),
482
  prevent_initial_call=True,
483
  )
484
+ def download_loe(n_clicks, loe_output):
485
+ if loe_output is None:
486
  return dash.no_update
487
+ loe_text = loe_output[0]['props']['children']
488
+ return dict(content=loe_text, filename="loe_report.md")
489
 
490
  if __name__ == '__main__':
491
  print("Starting the Dash application...")