Gregorfun's picture
Initial commit
32c5da4
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import Callable, Protocol
class ProviderUnavailableError(RuntimeError):
pass
@dataclass(slots=True)
class ProviderRequest:
prompt: str
negative_prompt: str
count: int
width: int
height: int
seed: int
steps: int
guidance: float
init_image_path: str | None = None
img2img_strength: float = 0.45
model_variant: str | None = None
@dataclass(slots=True)
class ProviderResult:
image_paths: list[Path]
ProgressCallback = Callable[[int, str], None]
CancelCallback = Callable[[], bool]
class IImageProvider(Protocol):
id: str
name: str
description: str
def is_available(self) -> bool:
...
def generate(
self,
request: ProviderRequest,
output_dir: Path,
progress: ProgressCallback,
is_cancelled: CancelCallback,
) -> ProviderResult:
...