Skip to content

Commit

Permalink
fix: allow unknown alchemy types; fix slow_workers default
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Mar 5, 2024
1 parent 22d0f09 commit bb8c072
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions horde_sdk/ai_horde_api/ai_horde_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ async def image_generate_request(
image_gen_request: ImageGenerateAsyncRequest,
timeout: int = GENERATION_MAX_LIFE,
check_callback: Callable[[ImageGenerateCheckResponse], None] | None = None,
delay: float = 0.0,
) -> tuple[ImageGenerateStatusResponse, JobID]:
"""Submit an image generation request to the AI-Horde API, and wait for it to complete.
Expand All @@ -1044,6 +1045,8 @@ async def image_generate_request(
AIHordeRequestError: If the request failed. The error response is included in the exception.
"""

await asyncio.sleep(delay)

timeout = self.validate_timeout(timeout, log_message=True)

n = image_gen_request.params.n if image_gen_request.params and image_gen_request.params.n else 1
Expand Down
6 changes: 3 additions & 3 deletions horde_sdk/ai_horde_api/apimodels/alchemy/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AlchemyAsyncRequestFormItem(HordeAPIDataObject):
def check_name(cls, v: KNOWN_ALCHEMY_TYPES | str) -> KNOWN_ALCHEMY_TYPES | str:
if isinstance(v, KNOWN_ALCHEMY_TYPES):
return v
if isinstance(v, str) and v not in KNOWN_ALCHEMY_TYPES.__members__:
if str(v) not in KNOWN_ALCHEMY_TYPES.__members__:
logger.warning(f"Unknown alchemy form name {v}. Is your SDK out of date or did the API change?")
return v

Expand All @@ -83,8 +83,8 @@ class AlchemyAsyncRequest(
forms: list[AlchemyAsyncRequestFormItem]
source_image: str
"""The public URL of the source image or a base64 string to use."""
slow_workers: bool = False
"""Whether to use the slower workers. Costs additional kudos if `True`."""
slow_workers: bool = True
"""Whether to use the slower workers. Costs additional kudos if `False`."""

@field_validator("forms")
def check_at_least_one_form(cls, v: list[AlchemyAsyncRequestFormItem]) -> list[AlchemyAsyncRequestFormItem]:
Expand Down
4 changes: 1 addition & 3 deletions horde_sdk/ai_horde_api/apimodels/alchemy/_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class AlchemyFormStatus(HordeAPIDataObject):
def validate_form(cls, v: str | KNOWN_ALCHEMY_TYPES) -> KNOWN_ALCHEMY_TYPES | str:
if isinstance(v, KNOWN_ALCHEMY_TYPES):
return v
if (isinstance(v, str) and v not in KNOWN_ALCHEMY_TYPES.__members__) or (
not isinstance(v, KNOWN_ALCHEMY_TYPES)
):
if str(v) not in KNOWN_ALCHEMY_TYPES.__members__:
logger.warning(f"Unknown form type {v}. Is your SDK out of date or did the API change?")
return v

Expand Down
2 changes: 1 addition & 1 deletion horde_sdk/generic_api/apimodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class RequestUsesImageWorkerMixin(BaseModel):
"""Mix-in class to describe an endpoint for which you can specify workers."""

trusted_workers: bool = False
slow_workers: bool = False
slow_workers: bool = True
workers: list[str] = Field(default_factory=list)
worker_blacklist: list[str] = Field(default_factory=list)

Expand Down

0 comments on commit bb8c072

Please sign in to comment.