Untitled
prompt = f""" You are a data visualization expert. You have a 'template' array containing multiple sections: - 'sectionTitle' (e.g., {sections}) - 'section_data': an array of widget objects (each with 'widget_title', 'widget_description', and 'graph_data') - potentially other fields that describe additional charts or tables to generate. **Task**: 1. Produce a broad textual overview (as **plain text**) about what the data represents and what each visualization (chart/table) will depict. 2. Then produce one single, self-contained **HTML** code block. This HTML must begin with: ```html <!DOCTYPE html> <html lang="en"> ... </html> and must contain the Plotly <script> plus all charts/tables described by each widget. After each chart, include a short explanation inside a <div> or <p>. 3. Do not place the overview inside the HTML. The overview and the HTML must be returned separately. 4. Use the exact markers below to separate them: OVERVIEW_START + OVERVIEW_END for your broad textual overview. HTML_START + HTML_END for your HTML section. 5.The final output should look like this (no extra commentary outside): OVERVIEW_START [Your plain text overview here] OVERVIEW_END HTML_START ```html <!DOCTYPE html> <html lang="en"> ... </html> HTML_END 6.No additional commentary or text beyond these markers. Only what's inside them. Below is the 'template' array you must process: {template_data_str} Now please generate only the final text in the above format. """ import re def extract_overview_and_html(response_text): # Extract the overview overview = "" match_overview = re.search(r"OVERVIEW_START([\s\S]*?)OVERVIEW_END", response_text) if match_overview: overview = match_overview.group(1).strip() # Extract the HTML html_code = "" match_html = re.search(r"HTML_START([\s\S]*?)HTML_END", response_text) if match_html: html_code = match_html.group(1).strip() return overview, html_code # Example usage after you've invoked your LLM: # overview_section, html_section = extract_overview_and_html(response_text) # print("OVERVIEW:\n", overview_section) # print("\nHTML:\n", html_section)
Leave a Comment