from __future__ import annotations from typing import Callable ProgressCallback = Callable[[float, str | None], None] def call_progress(progress: ProgressCallback | None, value: float, description: str | None = None) -> None: """Safely invoke a progress callback if it is provided.""" if progress is None: return try: progress(value, description) except Exception: # Progress callbacks should not break generation return