| 1 | """Structural typing contracts for rendering backends. |
| 2 | |
| 3 | Any class that exposes the right method signatures satisfies these |
| 4 | protocols -- no inheritance required. Existing generators (Google, |
| 5 | Yunwu/Doubao, Yunwu/Veo) are already compliant by duck typing. |
| 6 | """ |
| 7 | |
| 8 | from typing import List, Protocol, runtime_checkable |
| 9 | |
| 10 | from interfaces.image_output import ImageOutput |
| 11 | from interfaces.video_output import VideoOutput |
| 12 | |
| 13 | |
| 14 | @runtime_checkable |
| 15 | class ImageGenerator(Protocol): |
| 16 | """Generates a single image from a text prompt and optional reference images.""" |
| 17 | |
| 18 | async def generate_single_image( |
| 19 | self, |
| 20 | prompt: str, |
| 21 | reference_image_paths: List[str], |
| 22 | **kwargs, |
| 23 | ) -> ImageOutput: ... |
| 24 | |
| 25 | |
| 26 | @runtime_checkable |
| 27 | class VideoGenerator(Protocol): |
| 28 | """Generates a single video from a text prompt and optional reference images.""" |
| 29 | |
| 30 | async def generate_single_video( |
| 31 | self, |
| 32 | prompt: str, |
| 33 | reference_image_paths: List[str], |
| 34 | **kwargs, |
| 35 | ) -> VideoOutput: ... |
| 36 |