Skip to content

Commit

Permalink
fix: allow arbitrary sampler/upscaler names (enables tolerating API c…
Browse files Browse the repository at this point in the history
…hanges)
  • Loading branch information
tazlin committed Jan 8, 2024
1 parent 7b5219f commit 0cd3498
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion horde_sdk/ai_horde_api/apimodels/alchemy/_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class AlchemyUpscaleResult(BaseModel):
"""Represents the result of an upscale job."""

upscaler_used: KNOWN_UPSCALERS
upscaler_used: KNOWN_UPSCALERS | str
url: str


Expand Down
4 changes: 2 additions & 2 deletions horde_sdk/ai_horde_api/apimodels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ImageGenerateParamMixin(BaseModel):

model_config = ConfigDict(frozen=True) # , extra="forbid")

sampler_name: KNOWN_SAMPLERS = KNOWN_SAMPLERS.k_lms
sampler_name: KNOWN_SAMPLERS | str = KNOWN_SAMPLERS.k_lms
"""The sampler to use for this generation. Defaults to `KNOWN_SAMPLERS.k_lms`."""
cfg_scale: float = 7.5
"""The cfg_scale to use for this generation. Defaults to 7.5."""
Expand Down Expand Up @@ -169,7 +169,7 @@ def width_divisible_by_64(cls, value: int) -> int:
def sampler_name_must_be_known(cls, v: str | KNOWN_SAMPLERS) -> str | KNOWN_SAMPLERS:
"""Ensure that the sampler name is in this list of supported samplers."""
if v not in KNOWN_SAMPLERS.__members__:
raise ValueError(f"Unknown sampler name {v}")
logger.warning(f"Unknown sampler name {v}. Is your SDK out of date or did the API change?")
return v

# @model_validator(mode="after")
Expand Down

0 comments on commit 0cd3498

Please sign in to comment.