39 lines
833 B
Python
39 lines
833 B
Python
"""Shared types for image-generation providers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Protocol
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class SourceImage:
|
|
"""A binary source image passed into an image-generation provider."""
|
|
|
|
url: str
|
|
mime_type: str
|
|
data: bytes
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class GeneratedImageResult:
|
|
"""Normalized image-generation output returned by providers."""
|
|
|
|
image_bytes: bytes
|
|
mime_type: str
|
|
provider: str
|
|
model: str
|
|
prompt: str
|
|
|
|
|
|
class ImageGenerationProvider(Protocol):
|
|
"""Contract implemented by concrete image-generation providers."""
|
|
|
|
async def generate_tryon_image(
|
|
self,
|
|
*,
|
|
prompt: str,
|
|
person_image: SourceImage,
|
|
garment_image: SourceImage,
|
|
) -> GeneratedImageResult: ...
|