Skip to content

[WIP] Add AI-generated PowerPoint workflow using enterprise template#1

Draft
Copilot wants to merge 1 commit into
masterfrom
copilot/add-ai-generated-presentation-workflow
Draft

[WIP] Add AI-generated PowerPoint workflow using enterprise template#1
Copilot wants to merge 1 commit into
masterfrom
copilot/add-ai-generated-presentation-workflow

Conversation

Copy link
Copy Markdown

Copilot AI commented May 12, 2026

  • Create src/pptx/ai_workflow/ package with:
    • __init__.py – public exports
    • template_inspector.py – inspect layouts/placeholders in enterprise template
    • renderer.py – render LLM JSON slides into a Presentation using the template
    • validator.py – validate LLM JSON against schema rules
    • schema.py – LLM output JSON schema / dataclasses
  • Add tests/test_ai_workflow.py covering all new utilities
  • Add docs/user/enterprise-ai-workflow.rst specification & guide document
  • Verify all 2700 existing tests still pass after additions
Original prompt

Build support for an AI-generated PowerPoint workflow that uses a company/default enterprise PowerPoint template as the required starting point.

Context from user:

  • Repository: devendrabogati/python-pptx
  • Branch/ref: master
  • The user is building AI-generated PPTs.
  • Their company has a default enterprise template that must be used by an LLM-generated presentation workflow.

Required outcome:

  1. Add or document a practical implementation pattern for generating presentations from structured LLM output while always loading an existing enterprise .pptx template via Presentation(template_path) rather than starting from Presentation().
  2. The solution should emphasize using slide layouts and placeholders from the enterprise template, because python-pptx treats a template as a normal PowerPoint file with slides removed/kept as desired; themes, slide masters, layouts, branding, logos, fonts, and placeholder formatting are preserved from the starting deck.
  3. Provide code utilities/examples that:
    • Inspect available slide layouts and placeholder idx, name, and type values in the enterprise template.
    • Map LLM JSON slide types such as title, bullets, image, chart, and table to specific template layout indices and placeholder indices.
    • Render text into title/body placeholders.
    • Insert pictures into picture placeholders when available.
    • Insert tables/charts into table/chart placeholders when available, otherwise use slide.shapes.add_table() / slide.shapes.add_chart() as fallback.
    • Add speaker notes from LLM output.
    • Save the generated .pptx output.
  4. Include a clear requirements/specification document for the company/enterprise-template LLM workflow, covering:
    • Inputs: topic/prompt, template path, optional data/images, structured LLM JSON.
    • Template requirements: layouts, placeholder names/idx, aspect ratio, theme colors, corporate fonts, logos, notes master.
    • LLM output schema: title, subtitle, slides array, slide type, bullets, table data, chart data, images, notes.
    • Validation rules: max bullets, max words per bullet, required placeholders, allowed chart types, image path validation, fallback behavior.
    • Generation pipeline: prompt -> LLM JSON -> validation -> python-pptx renderer -> enterprise template -> output .pptx.
    • Risks/limitations: python-pptx limited animation/transition/SmartArt support, placeholder references become invalid after rich-content insertion, template layout indices must be discovered rather than assumed.
  5. Add tests if appropriate for any new utility code.

Important implementation guidance based on python-pptx docs:

  • Load enterprise template with prs = Presentation("enterprise_template.pptx").
  • Use prs.slide_layouts[index] but do not assume built-in indices if using a custom template; provide an inspection step.
  • Access placeholders using slide.placeholders[idx]; this uses placeholder idx, not list position.
  • Picture/table/chart placeholder insertion methods replace the original placeholder reference, so use returned objects after insertion.
  • Charts are contained in a graphic frame; slide.shapes.add_chart(...).chart accesses the chart.
  • Tables are contained in a graphic frame; slide.shapes.add_table(...).table accesses the table.
  • Use theme/template styles wherever possible rather than hard-coded formatting.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: can u teach complete python-pptx

Assistant: Absolutely — I can teach you python-pptx from beginner to practical advanced usage.

python-pptx is a Python library used to create, edit, and automate PowerPoint .pptx files. It is useful for AI-generated PPTs, reports, dashboards, business presentations, chart decks, and automated slide generation.


1. Install python-pptx

pip install python-pptx

Main dependencies include:

  • lxml
  • Pillow
  • XlsxWriter for charts

2. Basic Idea of python-pptx

Everything starts with a Presentation object.

from pptx import Presentation

prs = Presentation()
prs.save("output.pptx")

This creates a blank PowerPoint file using the default template.

You can also open an existing PowerPoint file:

from pptx import Presentation

prs = Presentation("template.pptx")
prs.save("new_output.pptx")

This is very important for AI-generated PPTs because you can use a branded company template.


3. Slides and Slide Layouts

Every slide is created from a slide layout.

Common default layouts:

Index Layout
0 Title Slide
1 Title and Content
2 Section Header
3 Two Content
4 Comparison
5 Title Only
6 Blank
7 Content with Caption
8 Picture with Caption

Example:

from pptx import Presentation

prs = Pre...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants