cddb07a176
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from logging import Logger
|
|
|
|
from invokeai.app.services.config import InvokeAIAppConfig
|
|
from invokeai.app.services.external_generation.external_generation_common import (
|
|
ExternalGenerationRequest,
|
|
ExternalGenerationResult,
|
|
ExternalProviderStatus,
|
|
)
|
|
|
|
|
|
class ExternalProvider(ABC):
|
|
provider_id: str
|
|
|
|
def __init__(self, app_config: InvokeAIAppConfig, logger: Logger) -> None:
|
|
self._app_config = app_config
|
|
self._logger = logger
|
|
|
|
@abstractmethod
|
|
def is_configured(self) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def generate(self, request: ExternalGenerationRequest) -> ExternalGenerationResult:
|
|
raise NotImplementedError
|
|
|
|
def get_status(self) -> ExternalProviderStatus:
|
|
return ExternalProviderStatus(provider_id=self.provider_id, configured=self.is_configured())
|
|
|
|
|
|
class ExternalGenerationServiceBase(ABC):
|
|
@abstractmethod
|
|
def generate(self, request: ExternalGenerationRequest) -> ExternalGenerationResult:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_provider_statuses(self) -> dict[str, ExternalProviderStatus]:
|
|
raise NotImplementedError
|