Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -79,8 +79,9 @@ app.layout = dbc.Container([
|
|
79 |
dcc.Loading(
|
80 |
id="loading-indicator",
|
81 |
type="dot",
|
82 |
-
children=[html.Div(id="
|
83 |
),
|
|
|
84 |
dbc.Button("Download Document", id="btn-download", color="success", className="mt-3"),
|
85 |
dcc.Download(id="download-document"),
|
86 |
html.Hr(),
|
@@ -183,7 +184,7 @@ Instructions:
|
|
183 |
2. Use proper formatting and structure.
|
184 |
3. Include all necessary sections and details.
|
185 |
4. Start the output immediately with the document content.
|
186 |
-
5. Your goal is to be compliant based on the
|
187 |
requrements, write in paragraph in active voice as
|
188 |
MicroHealth, limit bullets, answer the
|
189 |
requirement with what MicroHealth will do
|
@@ -210,7 +211,8 @@ Now, generate the {document_type}:
|
|
210 |
|
211 |
@app.callback(
|
212 |
Output('document-preview', 'children'),
|
213 |
-
Output('
|
|
|
214 |
Output('pink-review-upload', 'style'),
|
215 |
[Input(f'btn-{doc_type.lower().replace("_", "-")}', 'n_clicks') for doc_type in document_types.keys()],
|
216 |
State('pink-review-file-name', 'children'),
|
@@ -226,27 +228,27 @@ def generate_document_preview(*args):
|
|
226 |
pink_review_file = args[-1]
|
227 |
|
228 |
if not uploaded_files and document_type != "Shred":
|
229 |
-
return html.Div("Please upload and shred a document first."), "Please upload and shred a document first.", {'display': 'none'}
|
230 |
|
231 |
if document_type == "Shred":
|
232 |
if not uploaded_files:
|
233 |
-
return html.Div("Please upload a document before shredding."), "Please upload a document before shredding.", {'display': 'none'}
|
234 |
file_contents = list(uploaded_files.values())
|
235 |
try:
|
236 |
shredded_document = generate_document(document_type, file_contents)
|
237 |
-
return dcc.Markdown(shredded_document), "Document shredded. You can now proceed with other operations.", {'display': 'none'}
|
238 |
except Exception as e:
|
239 |
print(f"Error generating document: {str(e)}")
|
240 |
-
return html.Div(f"Error generating document: {str(e)}"), "An error occurred while shredding the document.", {'display': 'none'}
|
241 |
|
242 |
if shredded_document is None:
|
243 |
-
return html.Div("Please shred a document first."), "Please shred a document first.", {'display': 'none'}
|
244 |
|
245 |
if document_type == "Pink Review":
|
246 |
-
return html.Div("Please upload a Pink Team document or use the generated one."), "Please upload a Pink Team document or use the generated one.", {'display': 'block'}
|
247 |
|
248 |
if document_type in ["Red", "Red Review"] and pink_review_document is None:
|
249 |
-
return html.Div("Please complete Pink Review first."), "Please complete Pink Review first.", {'display': 'none'}
|
250 |
|
251 |
try:
|
252 |
if document_type == "Pink Review" and pink_review_file:
|
@@ -259,11 +261,11 @@ def generate_document_preview(*args):
|
|
259 |
if document_type == "Pink Review":
|
260 |
pink_review_document = current_document
|
261 |
|
262 |
-
return dcc.Markdown(current_document), f"{document_type} document generated successfully.", {'display': 'none'}
|
263 |
except Exception as e:
|
264 |
print(f"Error generating document: {str(e)}")
|
265 |
-
return html.Div(f"Error generating document: {str(e)}"), "An error occurred while generating the document.", {'display': 'none'}
|
266 |
-
|
267 |
@app.callback(
|
268 |
Output('pink-review-file-name', 'children'),
|
269 |
Input('upload-pink-review', 'contents'),
|
|
|
79 |
dcc.Loading(
|
80 |
id="loading-indicator",
|
81 |
type="dot",
|
82 |
+
children=[html.Div(id="loading-output")]
|
83 |
),
|
84 |
+
html.Div(id='document-preview', className="border p-3 mb-3"),
|
85 |
dbc.Button("Download Document", id="btn-download", color="success", className="mt-3"),
|
86 |
dcc.Download(id="download-document"),
|
87 |
html.Hr(),
|
|
|
184 |
2. Use proper formatting and structure.
|
185 |
3. Include all necessary sections and details.
|
186 |
4. Start the output immediately with the document content.
|
187 |
+
5. Your goal is to be compliant and compelling based on the
|
188 |
requrements, write in paragraph in active voice as
|
189 |
MicroHealth, limit bullets, answer the
|
190 |
requirement with what MicroHealth will do
|
|
|
211 |
|
212 |
@app.callback(
|
213 |
Output('document-preview', 'children'),
|
214 |
+
Output('loading-output', 'children'),
|
215 |
+
Output('status-bar', 'children', allow_duplicate=True),
|
216 |
Output('pink-review-upload', 'style'),
|
217 |
[Input(f'btn-{doc_type.lower().replace("_", "-")}', 'n_clicks') for doc_type in document_types.keys()],
|
218 |
State('pink-review-file-name', 'children'),
|
|
|
228 |
pink_review_file = args[-1]
|
229 |
|
230 |
if not uploaded_files and document_type != "Shred":
|
231 |
+
return html.Div("Please upload and shred a document first."), "", "Please upload and shred a document first.", {'display': 'none'}
|
232 |
|
233 |
if document_type == "Shred":
|
234 |
if not uploaded_files:
|
235 |
+
return html.Div("Please upload a document before shredding."), "", "Please upload a document before shredding.", {'display': 'none'}
|
236 |
file_contents = list(uploaded_files.values())
|
237 |
try:
|
238 |
shredded_document = generate_document(document_type, file_contents)
|
239 |
+
return dcc.Markdown(shredded_document), f"{document_type} generated", "Document shredded. You can now proceed with other operations.", {'display': 'none'}
|
240 |
except Exception as e:
|
241 |
print(f"Error generating document: {str(e)}")
|
242 |
+
return html.Div(f"Error generating document: {str(e)}"), "Error", "An error occurred while shredding the document.", {'display': 'none'}
|
243 |
|
244 |
if shredded_document is None:
|
245 |
+
return html.Div("Please shred a document first."), "", "Please shred a document first.", {'display': 'none'}
|
246 |
|
247 |
if document_type == "Pink Review":
|
248 |
+
return html.Div("Please upload a Pink Team document or use the generated one."), "", "Please upload a Pink Team document or use the generated one.", {'display': 'block'}
|
249 |
|
250 |
if document_type in ["Red", "Red Review"] and pink_review_document is None:
|
251 |
+
return html.Div("Please complete Pink Review first."), "", "Please complete Pink Review first.", {'display': 'none'}
|
252 |
|
253 |
try:
|
254 |
if document_type == "Pink Review" and pink_review_file:
|
|
|
261 |
if document_type == "Pink Review":
|
262 |
pink_review_document = current_document
|
263 |
|
264 |
+
return dcc.Markdown(current_document), f"{document_type} generated", f"{document_type} document generated successfully.", {'display': 'none'}
|
265 |
except Exception as e:
|
266 |
print(f"Error generating document: {str(e)}")
|
267 |
+
return html.Div(f"Error generating document: {str(e)}"), "Error", "An error occurred while generating the document.", {'display': 'none'}
|
268 |
+
|
269 |
@app.callback(
|
270 |
Output('pink-review-file-name', 'children'),
|
271 |
Input('upload-pink-review', 'contents'),
|