Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft PowerPoint document AI editor

This project turns a PowerPoint file written as slide-building instructions into a polished presentation. It reads the source deck, uses a local Ollama model to understand the intent of each slide, rewrites only the instruction text blocks, and preserves the existing PowerPoint structure and styling.

Optional enrichment: if the instruction text or slide notes reference URLs or local documents (PDF / DOCX), the tool fetches and summarises that content before generating the slide text, giving the model real source material to work from.

Goal

Take a presentation containing instructions — prompts, placeholders, or highlighted text — and generate the corresponding final slide content directly inside the deck, in the same language and style.

Main features

  • Reads a .pptx file and processes all slides recursively.
  • Uses Ollama to infer the global context of the document (intent, tone, audience).
  • Treats yellow-highlighted text (and only those runs) as instruction text.
  • Generates final content only for highlighted instruction blocks.
  • Keeps non-highlighted text unchanged.
  • Leaves title placeholders unchanged.
  • Preserves existing PowerPoint styling: font family, size, bold, italic, underline, color.
  • Formats rewritten paragraphs as justified text.
  • Slide-friendly output: bullet lists, short paragraphs, controlled emphasis.
  • Recursive traversal of text boxes, table cells, and grouped shapes.
  • Slide exclusion via a configurable range/list syntax.

Web pages analyzer

If an http:// or https:// URL appears inside a yellow-highlighted instruction block or in the slide notes, the tool will:

  1. Fetch the page over HTTP.
  2. Strip all HTML markup and extract plain text (up to WEB_PAGE_EXTRACT_CHARS characters).
  3. Ask Ollama to summarise the page content in the context of the slide instruction.
  4. Inject the summary into the generation prompt as reference material.

This lets you cite live web sources directly in your instruction text (e.g. "summarise the stats from https://example.com/report") without any manual copy-pasting.

Local document context (PDF & DOCX)

If a path ending in .pdf or .docx appears inside a highlighted instruction block or in the slide notes, the tool will:

  1. Resolve the path (relative paths are resolved against the directory of the input PPTX).
  2. Extract plain text from the file (up to LOCAL_DOC_EXTRACT_CHARS characters).
    • PDF extraction uses pypdf.
    • DOCX extraction uses python-docx.
  3. Ask Ollama to summarise the document content in the context of the slide.
  4. Inject the summary into the generation prompt.

Both URL and document summaries can be combined in the same slide when multiple sources are cited.

How it works

  1. Open the input PowerPoint document.
  2. Extract all text (up to 10 000 characters) to build a global context.
  3. Ask Ollama to summarise intent, tone, and audience.
  4. For each slide: extract slide title and notes.
  5. For each yellow-highlighted paragraph: detect URLs and local document paths in the text and notes.
  6. Fetch and summarise any external sources with Ollama.
  7. Generate the final slide text using the instruction, context, style hints, and source summaries.
  8. Write the generated text back into the slide, preserving the original run styling.

Project structure

powerpoint_document_ai_editor.py   Entry point and orchestration.
config.py                          All tuneable constants.
core/
  __init__.py
  ai_client.py       Ollama API calls and prompt-based generation.
  web_reader.py      URL fetching and LLM summarization.
  doc_reader.py      Local PDF/DOCX reading and LLM summarization.
  pptx_styling.py    Run-style snapshot/restore, text normalization.
  pptx_processor.py  Slide/shape traversal, instruction dispatch.

Slide Exclusion

Configure slides that must not be edited with IGNORED_SLIDES_SPEC in config.py.

Supported syntax examples:

  • "1,2,3"
  • "1-3"
  • "1-3,5,6-8"

Excluded slides are still included in the global context extraction so the model can better infer tone and audience.

Configuration

All settings live in config.py. Edit that file before running.

Core settings

Constant Description
INPUT_PPTX_PATH Path to the source presentation.
OUTPUT_PPTX_PATH Path where the generated presentation is saved.
OLLAMA_URL Base URL of the Ollama instance.
MODEL_CONTEXT Model identifier as shown in ollama list.
IGNORED_SLIDES_SPEC Slides to skip (see above).

Generation style tuning

Constant Description
MAX_BULLETS_PER_BLOCK Maximum number of bullet lines per instruction block.
MAX_CHARS_PER_BULLET Maximum characters per bullet line.
MAX_SENTENCES_PER_PARAGRAPH Maximum sentences when generating paragraph-style text.
MAX_TOTAL_CHARS_PER_BLOCK Hard cap on total characters per generated block.

⚠️ Resource-intensive settings

The following constants directly affect how many tokens are sent to the model and therefore how much CPU / GPU / RAM is consumed and how long each request takes.

Constant Default Impact
MODEL_NUM_CTX 65536 Context window size in tokens. Largest single factor for VRAM usage. Larger values let the model see more of the document and sources at once, but require proportionally more VRAM and increase per-request latency. Set to 0 to use the model's built-in default.
REQUEST_TIMEOUT_SECONDS 500 Per-request HTTP timeout. Increase only if the model is very slow.
WEB_PAGE_EXTRACT_CHARS 15000 Characters extracted from each fetched webpage before passing to the model. A very high value means more tokens in the prompt → more VRAM, slower generation.
LOCAL_DOC_EXTRACT_CHARS 15000 Characters extracted from each local PDF/DOCX. Same trade-off as above.
WEB_SUMMARY_MAX_CHARS 1200 Maximum characters kept from each source summary before injecting into the slide-generation prompt. Keeps the final prompt size controlled even when sources are large.

Practical guidance:

  • On a GPU with 8 GB VRAM, MODEL_NUM_CTX = 8192 is a safe starting point.
  • Set WEB_PAGE_EXTRACT_CHARS and LOCAL_DOC_EXTRACT_CHARS to 35005000 for faster runs with less memory pressure.
  • Increasing WEB_SUMMARY_MAX_CHARS gives the model richer source material but also grows the final prompt.

Requirements

  • Python 3.10+
  • Ollama running locally or remotely with at least one model loaded (e.g. gemma4, qwen3)
  • pypdf and python-docx are optional; the script runs without them but PDF/DOCX enrichment is disabled.

Note: The quality of the generated content depends primarily on the model. More capable models (larger context, better instruction-following) produce better results, especially for domain-specific content.

Tip: gemma4 currently offers a good balance between effectiveness and speed.

Install Python dependencies:

pip install -r requirements.txt

Usage

  1. Place your source .pptx file in the workspace.
  2. Edit INPUT_PPTX_PATH and OUTPUT_PPTX_PATH in config.py if needed.
  3. Highlight in yellow every text run you want the model to rewrite.
  4. Optionally add URLs or local document paths (.pdf, .docx) in the instruction text or slide notes to provide source material.
  5. Run:
python powerpoint_document_ai_editor.py

The generated presentation is written to OUTPUT_PPTX_PATH.

Output Behavior

Generated slide text is:

  • concise and slide-ready
  • justified
  • formatted with controlled bullets or short paragraphs
  • in the same language as the source instructions
  • grounded in cited source material when URLs or documents are provided

Notes

  • Titles are never rewritten.
  • Only yellow-highlighted runs are replaced; all other text is left unchanged.
  • Original font styling is preserved run-by-run.
  • If Ollama is unreachable the script stops early with an error.
  • If generation fails for a block, the original instruction text is kept as a fallback.
  • Both URL and document enrichment are purely passive: the tool only reads sources the author explicitly cites; it never performs autonomous web searches.

Maintenance policy

This project is shared publicly but maintained on a best-effort basis. Contributions and pull requests are welcome.

License

This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE. See LICENSE for license information.

About

Use local AI model to turn a PowerPoint draft template file as slide-building instructions into a polished presentation.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages