mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:29:37 +08:00
Chat attachments base64-inline every harvested image into one provider request, and the byte budgets did not bound what a *page-sized* raster costs there: a scanned A4 page arrives at ~2900x4032 (~600 KB), so a seven-page scan rode along as ~4.2 MB of body / ~5.6 MB encoded even though the model is served a raster scaled toward ~1.5k on the long edge anyway. Fit a candidate to MAX_INLINE_IMAGE_EDGE (1600) before the byte budgets weigh it, so the budgets measure what will actually ship. An image already within the bound keeps its bytes and its format; re-encoding is reserved for rasters past it, at the same jpg_quality (82) the reading viewport's whole-page render already uses. Every failure path returns the original bytes, and a pixel count past MAX_INLINE_FIT_PIXELS is refused before Pillow allocates for it. The reading-area ingest keeps source resolution (max_inline_edge=0) because those images are written to disk for the reader pane. The PPTX and DOCX ingests were still on the chat-attachment budget by default, so they now pass the reading budget like the PDF ingest already did.