Guiyom commited on
Commit
9978a7a
·
verified ·
1 Parent(s): 167be5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -39,7 +39,7 @@ def replace_focus_placeholders(report_html: str, context: str, initial_query: st
39
  try:
40
  focus_html = generate_focus_snippet(instructions, context, initial_query, crumbs)
41
  # Wrap the entire focus placeholder in a single div to preserve block-level grouping.
42
- return f'<!-- Focus {placeholder_num} Start --><div class="focus-placeholder" style="background: #ede8e8; border: 1px solid black; padding: 10px; margin: 10px 0;">\n{focus_html}\n</div><!-- Focus {placeholder_num} End -->'
43
  except Exception as e:
44
  logging.error(f"Focus {placeholder_num} failed: {str(e)}")
45
  return f'<!-- ERROR GENERATING FOCUS {placeholder_num} -->'
@@ -838,17 +838,19 @@ class ReportGenerator:
838
  <head>
839
  <meta charset="utf-8" />
840
  <style>
841
- body {{ font-family: Helvetica, sans-serif; margin: 40px; background: white; }}
842
- h1 {{ font-size: 24pt; margin-bottom: 12px; text-align: left; }}
843
- h2 {{ font-size: 20pt; margin-bottom: 10px; text-align: left; }}
844
- h3 {{ font-size: 18pt; margin-bottom: 8px; text-align: left; }}
845
- p {{ font-size: 11pt; line-height: 1.5; margin-bottom: 10px; }}
846
- ol, ul {{ font-size: 11pt; margin-left: 20px; line-height: 1.5; }}
847
- hr {{ border: 1px solid #ccc; margin: 20px 0; }}
848
- table {{ border-collapse: collapse; width: 100%; margin-bottom: 10px; }}
849
- th, td {{ border: 1px solid #ccc; padding: 8px; text-align: left; }}
850
- th {{ background-color: #f2f2f2; }}
851
- .page-break {{ page-break-before: always; }}
 
 
852
  </style>
853
  <script>
854
  console.log("Report loaded successfully.");
@@ -879,7 +881,7 @@ class ReportGenerator:
879
  driver = webdriver.Chrome(options=options)
880
  try:
881
  driver.get(f"data:text/html;charset=utf-8,{html_content}")
882
- time.sleep(2)
883
  screenshot_png = driver.get_screenshot_as_png()
884
  return screenshot_png
885
  finally:
@@ -920,11 +922,6 @@ class ReportGenerator:
920
  svg { max-width: 100% !important; height: auto !important; }
921
  }
922
  """)
923
- # Wrap the alignment assessment (if present) in a div to control overflow.
924
- html_report = html_report.replace(
925
- "<p><b>Report alignment assessment:</b>",
926
- "<div style='max-width:100%; word-wrap: break-word;'><p><b>Report alignment assessment:</b>"
927
- )
928
  # Ensure closing tag for the added div.
929
  html_report = html_report.replace("</body>", "</div></body>")
930
 
@@ -1131,10 +1128,10 @@ def iterative_deep_research_gen(initial_query: str, reportstyle: str, breadth: i
1131
  final_report = replace_focus_placeholders(final_report, combined_context, initial_query, aggregated_crumbs)
1132
 
1133
  alignment_assessment = assess_report_alignment(final_report, initial_query, followup_clarifications)
1134
- final_report += f"""
1135
-
1136
- <p><b>Report alignment assessment:</b>
1137
- {alignment_assessment}</p>"""
1138
  logging.info("iterative_deep_research_gen: Final report generated.")
1139
  yield ("", final_report, process_log, crumbs_list)
1140
 
 
39
  try:
40
  focus_html = generate_focus_snippet(instructions, context, initial_query, crumbs)
41
  # Wrap the entire focus placeholder in a single div to preserve block-level grouping.
42
+ return f'<!-- Focus {placeholder_num} Start --><div class="focus-placeholder" style="background: #ede8e8; border: 1px solid black; padding: 10px; margin: 10px 0; font-size: 7pt;">\n">\n{focus_html}\n</div><!-- Focus {placeholder_num} End -->'
43
  except Exception as e:
44
  logging.error(f"Focus {placeholder_num} failed: {str(e)}")
45
  return f'<!-- ERROR GENERATING FOCUS {placeholder_num} -->'
 
838
  <head>
839
  <meta charset="utf-8" />
840
  <style>
841
+ body {{ font-family: Helvetica, sans-serif; margin: 40px; background: white; }}
842
+ h1 {{ font-size: 24pt; margin-bottom: 12px; text-align: left; }}
843
+ h2 {{ font-size: 20pt; margin-bottom: 10px; text-align: left; }}
844
+ h3 {{ font-size: 18pt; margin-bottom: 8px; text-align: left; }}
845
+ /* Force paragraphs to have a white background */
846
+ p {{ font-size: 11pt; line-height: 1.5; margin-bottom: 10px; background-color: white !important; }}
847
+ ol, ul {{ font-size: 11pt; margin-left: 20px; line-height: 1.5; }}
848
+ h2 + ol {{ line-height: 1 !important; }}
849
+ hr {{ border: 1px solid #ccc; margin: 20px 0; }}
850
+ table {{ border-collapse: collapse; width: 100%; margin-bottom: 10px; }}
851
+ th, td {{ border: 1px solid #ccc; padding: 8px; text-align: left; }}
852
+ th {{ background-color: #f2f2f2; }}
853
+ .page-break {{ page-break-before: always; }}
854
  </style>
855
  <script>
856
  console.log("Report loaded successfully.");
 
881
  driver = webdriver.Chrome(options=options)
882
  try:
883
  driver.get(f"data:text/html;charset=utf-8,{html_content}")
884
+ time.sleep(10)
885
  screenshot_png = driver.get_screenshot_as_png()
886
  return screenshot_png
887
  finally:
 
922
  svg { max-width: 100% !important; height: auto !important; }
923
  }
924
  """)
 
 
 
 
 
925
  # Ensure closing tag for the added div.
926
  html_report = html_report.replace("</body>", "</div></body>")
927
 
 
1128
  final_report = replace_focus_placeholders(final_report, combined_context, initial_query, aggregated_crumbs)
1129
 
1130
  alignment_assessment = assess_report_alignment(final_report, initial_query, followup_clarifications)
1131
+ final_report = final_report.replace(
1132
+ "</body>",
1133
+ f"<p><b>Report alignment assessment:</b> {alignment_assessment}</p></body>"
1134
+ )
1135
  logging.info("iterative_deep_research_gen: Final report generated.")
1136
  yield ("", final_report, process_log, crumbs_list)
1137