def _calculate_batch_size(self, pdf_path: str, reader) -> Tuple[int, int]:
        """Calculate number of pages and pages per batch."""
        num_pages = len(reader.pages)
        file_size = os.path.getsize(pdf_path)
        avg_page_size = file_size / num_pages if num_pages > 0 else 0

        # Calculate pages per batch to stay under 50MB limit (with 10% buffer)
        pages_per_batch = max(1, int((MAX_MISTRAL_FILE_SIZE * 0.9) / avg_page_size))

        logger.info(f"PDF has {num_pages} pages, avg {avg_page_size / 1024 / 1024:.2f}MB per page")
        logger.info(f"Processing in batches of {pages_per_batch} pages")

        return num_pages, pages_per_batch
Calculate number of pages and pages per batch.
backend/airweave/platform/file_handling/conversion/converters/pdf_converter.py