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.
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.
- Reads a
.pptxfile 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.
If an http:// or https:// URL appears inside a yellow-highlighted instruction block or in the slide notes, the tool will:
- Fetch the page over HTTP.
- Strip all HTML markup and extract plain text (up to
WEB_PAGE_EXTRACT_CHARScharacters). - Ask Ollama to summarise the page content in the context of the slide instruction.
- 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.
If a path ending in .pdf or .docx appears inside a highlighted instruction block or in the slide notes, the tool will:
- Resolve the path (relative paths are resolved against the directory of the input PPTX).
- Extract plain text from the file (up to
LOCAL_DOC_EXTRACT_CHARScharacters).- PDF extraction uses pypdf.
- DOCX extraction uses python-docx.
- Ask Ollama to summarise the document content in the context of the slide.
- Inject the summary into the generation prompt.
Both URL and document summaries can be combined in the same slide when multiple sources are cited.
- Open the input PowerPoint document.
- Extract all text (up to 10 000 characters) to build a global context.
- Ask Ollama to summarise intent, tone, and audience.
- For each slide: extract slide title and notes.
- For each yellow-highlighted paragraph: detect URLs and local document paths in the text and notes.
- Fetch and summarise any external sources with Ollama.
- Generate the final slide text using the instruction, context, style hints, and source summaries.
- Write the generated text back into the slide, preserving the original run styling.
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.
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.
All settings live in config.py. Edit that file before running.
| 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). |
| 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. |
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 = 8192is a safe starting point. - Set
WEB_PAGE_EXTRACT_CHARSandLOCAL_DOC_EXTRACT_CHARSto3500–5000for faster runs with less memory pressure. - Increasing
WEB_SUMMARY_MAX_CHARSgives the model richer source material but also grows the final prompt.
- Python 3.10+
- Ollama running locally or remotely with at least one model loaded (e.g.
gemma4,qwen3) pypdfandpython-docxare 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- Place your source
.pptxfile in the workspace. - Edit
INPUT_PPTX_PATHandOUTPUT_PPTX_PATHin config.py if needed. - Highlight in yellow every text run you want the model to rewrite.
- Optionally add URLs or local document paths (
.pdf,.docx) in the instruction text or slide notes to provide source material. - Run:
python powerpoint_document_ai_editor.pyThe generated presentation is written to OUTPUT_PPTX_PATH.
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
- 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.
This project is shared publicly but maintained on a best-effort basis. Contributions and pull requests are welcome.
This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE. See LICENSE for license information.