Hi guys I have a system in which an AI report is generated via Dify, and then the generated content, together with a predefined prompt stored locally, is sent to the Gamma API to automatically generate a PDF. However, we are encountering an issue where Gamma does not consistently follow the instructions in the prompt. For example, even when we explicitly request the generation of tables or line charts, Gamma often fails to produce them as specified. Do you have any recommended approaches or best practices to improve instruction adherence in this type of workflow? For instance, are there more effective prompt structures, parameter settings, or API usage patterns that can help ensure tables and charts are rendered correctly? Any guidance would be greatly appreciated.
Hey Kasei! ๐ Great question about chart generation! Here's the important thing to understand upfront: our chart and table creation is AI-powered, not a deterministic rendering system. This means the AI does its best to create visualizations based on your data, but it can't guarantee specific chart types every time. That said, there are some solid ways to improve your results! The most impactful change: use textMode: "preserve" This tells Gamma to keep your exact text and data structure while adding visuals, instead of rewriting everything. If you're not using this yet, it'll make a big difference. How to structure your data for better results:
Be explicit with your data formatting:
Use clear labels and numeric values
Format like "Q1: 100, Q2: 150, Q3: 200"
Keep labels short (2 words or less works best)
Be specific in your prompts:
Instead of: "Show revenue data"
Try: "Create a line chart showing quarterly revenue: Q1: 50000, Q2: 75000, Q3: 90000"
Technical constraints to know:
Pie/donut charts need 5-10 data points to work properly
Other chart types support 1-3 data columns
The AI gets examples of proper chart markup, but it's not guaranteed to follow them exactly
๐ก Quick win: If you're not already using textMode: "preserve", add that to your API calls first. That single change will give you the most control over your data structure. Are you currently using textMode: "preserve" in your requests? If not, I'd recommend trying that and seeing how it impacts your chart generation! Let me know if you need help implementing this or if you're still seeing issues after making these changes.
