bluenevus commited on
Commit
f9b7e87
·
verified ·
1 Parent(s): 15337c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -7
app.py CHANGED
@@ -129,12 +129,18 @@ def generate_red_document(document: str, compliance_report: str) -> str:
129
  response = model.generate_content(prompt)
130
  return response.text
131
 
132
- def generate_loe(document: str) -> Tuple[str, pd.DataFrame]:
 
 
 
 
 
 
133
  prompt = f"""
134
  Analyze the following document and provide a Level of Effort (LOE) breakdown:
135
 
136
  Document:
137
- {document}
138
 
139
  For each section header in the document:
140
  1. Identify the tasks to be completed
@@ -293,6 +299,21 @@ app.layout = dbc.Container([
293
  dcc.Download(id="download-g-review-doc")
294
  ]),
295
  dbc.Tab(label="LOE", tab_id="loe", children=[
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  dbc.Button("Generate LOE", id="generate-loe", className="mt-3"),
297
  dbc.Spinner(html.Div(id='loe-output')),
298
  dbc.Button("Download LOE Report", id="download-loe", className="mt-3"),
@@ -371,16 +392,19 @@ def update_g_review_output(n_clicks, contents, filename, requirements):
371
  @app.callback(
372
  Output('loe-output', 'children'),
373
  Input('generate-loe', 'n_clicks'),
 
374
  State('shred-output', 'children')
375
  )
376
- def update_loe_output(n_clicks, shred_output):
377
  if n_clicks is None:
378
  return "Click 'Generate LOE' to begin."
379
 
380
- if shred_output is None:
381
- return "Please complete the Shred tab first."
382
-
383
- loe_text, loe_df = generate_loe(shred_output)
 
 
384
 
385
  return [
386
  dcc.Markdown(loe_text),
 
129
  response = model.generate_content(prompt)
130
  return response.text
131
 
132
+ def generate_loe(document: str, is_file: bool = False) -> Tuple[str, pd.DataFrame]:
133
+ if is_file:
134
+ # Process the uploaded document
135
+ document_text = process_document(document, document.split(',')[0])
136
+ else:
137
+ document_text = document
138
+
139
  prompt = f"""
140
  Analyze the following document and provide a Level of Effort (LOE) breakdown:
141
 
142
  Document:
143
+ {document_text}
144
 
145
  For each section header in the document:
146
  1. Identify the tasks to be completed
 
299
  dcc.Download(id="download-g-review-doc")
300
  ]),
301
  dbc.Tab(label="LOE", tab_id="loe", children=[
302
+ dcc.Upload(
303
+ id='upload-loe',
304
+ children=html.Div(['Drag and Drop or ', html.A('Select Files')]),
305
+ style={
306
+ 'width': '100%',
307
+ 'height': '60px',
308
+ 'lineHeight': '60px',
309
+ 'borderWidth': '1px',
310
+ 'borderStyle': 'dashed',
311
+ 'borderRadius': '5px',
312
+ 'textAlign': 'center',
313
+ 'margin': '10px'
314
+ },
315
+ multiple=False
316
+ ),
317
  dbc.Button("Generate LOE", id="generate-loe", className="mt-3"),
318
  dbc.Spinner(html.Div(id='loe-output')),
319
  dbc.Button("Download LOE Report", id="download-loe", className="mt-3"),
 
392
  @app.callback(
393
  Output('loe-output', 'children'),
394
  Input('generate-loe', 'n_clicks'),
395
+ State('upload-loe', 'contents'),
396
  State('shred-output', 'children')
397
  )
398
+ def update_loe_output(n_clicks, upload_contents, shred_output):
399
  if n_clicks is None:
400
  return "Click 'Generate LOE' to begin."
401
 
402
+ if upload_contents:
403
+ loe_text, loe_df = generate_loe(upload_contents, is_file=True)
404
+ elif shred_output:
405
+ loe_text, loe_df = generate_loe(shred_output)
406
+ else:
407
+ return "Please upload a document or complete the Shred tab first."
408
 
409
  return [
410
  dcc.Markdown(loe_text),