Guiyom commited on
Commit
ec534d6
·
verified ·
1 Parent(s): 2666540

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -453,7 +453,7 @@ def remove_text_from_html(report_html: str, text_to_remove: str) -> str:
453
 
454
  def fix_visual_after_section(report_html: str, section_title: str, extra_instructions: str) -> str:
455
  """
456
- Given a report HTML, a target section name (extracted from within [[...]]), and extra instructions,
457
  this function finds the first header (h1–h4) that contains the section name (ignoring common TOC headers),
458
  then finds the first <iframe> following that header.
459
  It sends the current iframe 'srcdoc' (which should contain a mermaid diagram)
@@ -491,7 +491,8 @@ Return only the improved mermaid code (the content that should go inside the <di
491
  Ensure that the output starts with one of the following keywords: mindmap, flowchart, sequence, gantt, or pie."""
492
 
493
  improved_code = llm_call(prompt=prompt, model="o3-mini", temperature=0, max_tokens_param=1500)
494
- improved_code = improved_code.strip().strip("```").strip()
 
495
  logging.info(f"fix_visual_after_section: Improved code received from LLM:\n{improved_code}")
496
 
497
  # Verify that the result starts with a valid mermaid diagram keyword.
 
453
 
454
  def fix_visual_after_section(report_html: str, section_title: str, extra_instructions: str) -> str:
455
  """
456
+ Given a report HTML, a target section name (from inside [[...]]), and extra instructions,
457
  this function finds the first header (h1–h4) that contains the section name (ignoring common TOC headers),
458
  then finds the first <iframe> following that header.
459
  It sends the current iframe 'srcdoc' (which should contain a mermaid diagram)
 
491
  Ensure that the output starts with one of the following keywords: mindmap, flowchart, sequence, gantt, or pie."""
492
 
493
  improved_code = llm_call(prompt=prompt, model="o3-mini", temperature=0, max_tokens_param=1500)
494
+ # Remove code fence markers and all leading whitespace
495
+ improved_code = improved_code.replace("```", "").lstrip()
496
  logging.info(f"fix_visual_after_section: Improved code received from LLM:\n{improved_code}")
497
 
498
  # Verify that the result starts with a valid mermaid diagram keyword.