feat(pptx): client-side slide splitting for hi_res PPTX

BA
5mo ago
+915-59

Summary

Extends the SDK's client-side PDF page-splitting to PPTX decks. When split_pdf_page=true, strategy=hi_res, and the upload is a .pptx, the deck is split into slide-chunks that are partitioned in parallel and recombined — parallelizing the expensive per-slide hi_res work and avoiding large-payload timeouts. Each slide maps to one page (the server already partitions PPTX one page per slide).

PDF behavior is unchanged. Reuses the existing split_pdf_page flag, so there's no new API field.

How it works

  • New pptx_utils.py — stdlib-only (zipfile + xml/regex), no new dependency. Provides is_pptx, get_pptx_slide_count, and in-memory / cache-to-disk chunk builders. Each chunk is a minimal valid .pptx that keeps every shared part (masters, layouts, themes, notes master, media) and only the chunk's slides plus the notes slides they reference; presentation.xml, its .rels, and [Content_Types].xml are rewritten so nothing dangles.
  • request_utils.py — create_pdf_chunk_request is now a thin wrapper over a generalized create_document_chunk_request(..., content_type); PPTX chunks go out with the pptx content type and the original .pptx filename.
  • split_pdf_hook.py — one new branch in _before_request_unlocked, gated on strategy=hi_res + real .pptx. All downstream machinery (sizing defaults, concurrency, caching, retries, after_success recombination, cleanup) is shared with the PDF path. Legacy .ppt (OLE, not a zip) and non-hi_res requests fall through unsplit.

Verification

  • 233 unit tests pass (19 new in test_pptx_split.py); clean mypy. PDF path unchanged.
  • Structural — python-pptx (the server's own parser) opens the synthesized 1000-slide deck and every chunk with exact slide/notes counts; notes slides are preserved.
  • Live (stage) — 1000-slide deck → 50 parallel chunks → contiguous element pages 1..1000, 0 chunk failures.
  • Unchunked vs chunked A/B (60-slide deck, hi_res): ~1.5× faster (6.6s vs 10.0s) with 717/720 elements byte-identical. The only deltas are 3 parent_id links whose parent Title lives on a slide in a different chunk — an inherent property of independent-chunk partitioning, identical to the existing PDF page-split behavior.

🤖 Generated with Claude Code