bluenevus commited on
Commit
7f35ab1
·
verified ·
1 Parent(s): 01022d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -1
app.py CHANGED
@@ -145,7 +145,40 @@ def process_document(contents, filename):
145
  return f"Unsupported file format: {filename}. Please upload a PDF or DOCX file."
146
  except Exception as e:
147
  return f"Error processing document: {str(e)}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
 
 
149
  @app.callback(
150
  Output('file-list', 'children'),
151
  Output('status-bar', 'children'),
@@ -154,6 +187,7 @@ def process_document(contents, filename):
154
  State('file-list', 'children')
155
  )
156
  def update_output(list_of_contents, list_of_names, existing_files):
 
157
  global uploaded_files, shredded_document
158
  if list_of_contents is not None:
159
  new_files = []
@@ -170,6 +204,7 @@ def update_output(list_of_contents, list_of_names, existing_files):
170
  return existing_files + new_files, "Document uploaded. Please select a document type to proceed."
171
  return existing_files, "Please upload a document to begin."
172
 
 
173
  @app.callback(
174
  Output('file-list', 'children', allow_duplicate=True),
175
  Output('status-bar', 'children', allow_duplicate=True),
@@ -217,6 +252,7 @@ def show_document_options(*args):
217
  prevent_initial_call=True
218
  )
219
  def generate_document_preview(n_clicks, doc_source, uploaded_doc_name, *args):
 
220
  global current_document, document_type, shredded_document, generated_documents
221
  ctx = dash.callback_context
222
  if not ctx.triggered:
@@ -353,5 +389,8 @@ def download_document(n_clicks):
353
 
354
  if __name__ == '__main__':
355
  print("Starting the Dash application...")
356
- app.run(debug=False, host='0.0.0.0', port=7860)
 
 
 
357
  print("Dash application has finished running.")
 
145
  return f"Unsupported file format: {filename}. Please upload a PDF or DOCX file."
146
  except Exception as e:
147
  return f"Error processing document: {str(e)}"
148
+ def generate_document(document_type, file_contents):
149
+ print(f"Generating document for {document_type}") # Debug print
150
+ prompt = f"""Generate a {document_type} based on the following project artifacts:
151
+ {' '.join(file_contents)}
152
+ Instructions:
153
+ 1. Create the {document_type} as a detailed document.
154
+ 2. Use proper formatting and structure.
155
+ 3. Include all necessary sections and details.
156
+ 4. Start the output immediately with the document content.
157
+ 5. IMPORTANT: If the document type is Pink, Red, Gold and not review type, loe or board
158
+ then your goal is to be compliant and compelling based on the
159
+ requirements, write in paragraph in active voice as
160
+ MicroHealth, limit bullets, answer the
161
+ requirement with what MicroHealth will do
162
+ to satisfy the requirement, the technical
163
+ approach with innovation for efficiency,
164
+ productivity, quality and measurable
165
+ outcomes, the industry standard that
166
+ methodology is based on if applicable,
167
+ detail the workflow or steps to accomplish
168
+ the requirement with labor categories that
169
+ will do those tasks in that workflow,
170
+ reference reputable research like gartner,
171
+ forrester, IDC, Deloitte, Accenture etc
172
+ with measures of success and substantiation
173
+ of MicroHealth's approach. Never use soft words
174
+ like maybe, could be, should, possible be definitive in your language and confident.
175
+ 6. you must also take into account section L&M of the document which is the evaluation criteria
176
+ to be sure we address them.
177
+ Now, generate the {document_type}:
178
+ """
179
 
180
+ response = model.generate_content(prompt)
181
+ return response.text
182
  @app.callback(
183
  Output('file-list', 'children'),
184
  Output('status-bar', 'children'),
 
187
  State('file-list', 'children')
188
  )
189
  def update_output(list_of_contents, list_of_names, existing_files):
190
+ print("update_output callback triggered") # Debug print
191
  global uploaded_files, shredded_document
192
  if list_of_contents is not None:
193
  new_files = []
 
204
  return existing_files + new_files, "Document uploaded. Please select a document type to proceed."
205
  return existing_files, "Please upload a document to begin."
206
 
207
+
208
  @app.callback(
209
  Output('file-list', 'children', allow_duplicate=True),
210
  Output('status-bar', 'children', allow_duplicate=True),
 
252
  prevent_initial_call=True
253
  )
254
  def generate_document_preview(n_clicks, doc_source, uploaded_doc_name, *args):
255
+ print("generate_document_preview callback triggered") # Debug print
256
  global current_document, document_type, shredded_document, generated_documents
257
  ctx = dash.callback_context
258
  if not ctx.triggered:
 
389
 
390
  if __name__ == '__main__':
391
  print("Starting the Dash application...")
392
+ try:
393
+ app.run(debug=True, host='0.0.0.0', port=7860)
394
+ except Exception as e:
395
+ print(f"An error occurred while running the app: {str(e)}")
396
  print("Dash application has finished running.")