malepati/custom_template_working
0
1# Fix Chart Layout Selection - Implementation Plan2 3## Problem4Even after fixing the data injection (V3), charts are missing from slides.5**Root Cause:** The LLM responsible for selecting Slide Layouts (`generate_presentation_structure`) is picking layouts that *do not support charts* (e.g., simple bullet point layouts) because the existence of `chart_data` is not clearly highlighted in the prompt.6The current `to_string()` method relies on the default Pydantic string representation, which might be ambiguous or ignored by the LLM.7 8## Proposed Changes9 10### **servers/fastapi/models/presentation_outline_model.py**11 12**Function**: `to_string`13 14**Logic to Update**:15Change the string serialization to explicitly flag when a slide contains Chart Data.16 17**Code Snippet**:18```python19 def to_string(self):20 message = ""21 for i, slide in enumerate(self.slides):22 message += f"## Slide {i+1}:\n"23 message += f" - Content: {slide.content} \n"24 if slide.chart_data:25 message += f" - [IMPORTANT] INCLUDES CHART DATA: {slide.chart_data.title} (Type: {slide.chart_data.type}). YOU MUST SELECT A LAYOUT THAT SUPPORTS CHARTS.\n"26 return message27```28 29## Verification301. Restart Backend.312. Generate presentation with "Show me a bar chart of sales".323. Verify in the logs/UI that the "Chart Left Text Right" (or similar) layout is selected.334. Confirm the Chart appears.34 