Skip to content

object_models

Predicate module-attribute

Predicate = Callable[[Mapping[str, object]], bool]

AlchemyFeatureFlags

Bases: GenerationFeatureFlags

Feature flags for an alchemy worker.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class AlchemyFeatureFlags(GenerationFeatureFlags):
    """Feature flags for an alchemy worker."""

    alchemy_types: list[KNOWN_ALCHEMY_TYPES] = Field(default_factory=list)
    """The alchemy types supported by the worker."""

alchemy_types class-attribute instance-attribute

alchemy_types: list[KNOWN_ALCHEMY_TYPES] = Field(
    default_factory=list
)

The alchemy types supported by the worker.

model_config class-attribute instance-attribute

model_config = ConfigDict(use_attribute_docstrings=True)

extra_texts class-attribute instance-attribute

extra_texts: bool = Field(default=False)

Whether there is support for extra texts.

extra_source_images class-attribute instance-attribute

extra_source_images: bool = Field(default=False)

Whether there is support for extra source images.

SingleAlchemyParametersTemplate

Bases: CompositeParametersBase

Template for alchemy parameters with all fields optional.

Use this class during chain construction when not all parameters are known yet. Convert to SingleAlchemyParameters (or subclasses) before execution.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class SingleAlchemyParametersTemplate(CompositeParametersBase):
    """Template for alchemy parameters with all fields optional.

    Use this class during chain construction when not all parameters are known yet.
    Convert to SingleAlchemyParameters (or subclasses) before execution.
    """

    result_id: str | None = None
    """The generation ID to use for the generation."""

    form: KNOWN_ALCHEMY_FORMS | str | None = None
    """The form to use for the generation."""

    source_image: bytes | str | None = None
    """The source image to use for the generation."""

    @override
    def get_number_expected_results(self) -> int:
        """Get the number of expected results."""
        return 1

    def to_parameters(
        self,
        *,
        result_id: ID_TYPES | None = None,
        source_image: bytes | str | None = None,
        default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
        allocator: ResultIdAllocator | None = None,
        seed: str = "alchemy",
    ) -> SingleAlchemyParameters:
        """Convert this template into concrete alchemy generation parameters."""
        overrides: dict[str, object] = {}
        if source_image is not None:
            overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

        current_form = self.form
        if default_form is not None and current_form is None:
            overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

        finalization = finalize_template_for_parameters(
            self,
            overrides=overrides,
            exclude_none=False,
            fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
        )

        resolved_result_id = resolve_result_id_from_payload(
            explicit_id=result_id,
            payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
            allocator=allocator,
            seed=seed,
            fingerprint=finalization.fingerprint,
        )

        finalized_template = finalization.template.model_copy(
            update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
        )

        return self._instantiate_alchemy_parameters(finalized_template)

    @staticmethod
    def _instantiate_alchemy_parameters(
        payload: SingleAlchemyParametersTemplate | Mapping[str, object],
    ) -> SingleAlchemyParameters:
        """Instantiate the appropriate alchemy parameter model based on payload contents."""
        return instantiate_alchemy_parameters(payload)

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

SingleAlchemyParameters

Bases: CompositeParametersBase

Represents the common bare minimum parameters for any alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class SingleAlchemyParameters(CompositeParametersBase):
    """Represents the common bare minimum parameters for any alchemy generation."""

    result_id: str
    """The generation ID to use for the generation."""

    form: KNOWN_ALCHEMY_FORMS | str
    """The form to use for the generation."""

    source_image: bytes | str | None
    """The source image to use for the generation."""

    @override
    def get_number_expected_results(self) -> int:
        """Get the number of expected results."""
        return 1

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

form instance-attribute

form: KNOWN_ALCHEMY_FORMS | str

The form to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

UpscaleAlchemyParametersTemplate

Bases: SingleAlchemyParametersTemplate

Template for upscale alchemy parameters with all fields optional.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class UpscaleAlchemyParametersTemplate(SingleAlchemyParametersTemplate):
    """Template for upscale alchemy parameters with all fields optional."""

    upscaler: KNOWN_UPSCALERS | str | None = None

upscaler class-attribute instance-attribute

upscaler: KNOWN_UPSCALERS | str | None = None

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

UpscaleAlchemyParameters

Bases: SingleAlchemyParameters

Represents the parameters for an upscale alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class UpscaleAlchemyParameters(SingleAlchemyParameters):
    """Represents the parameters for an upscale alchemy generation."""

    form: Literal[KNOWN_ALCHEMY_FORMS.post_process] = KNOWN_ALCHEMY_FORMS.post_process

    upscaler: KNOWN_UPSCALERS | str

form class-attribute instance-attribute

form: Literal[post_process] = post_process

upscaler instance-attribute

upscaler: KNOWN_UPSCALERS | str

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

FacefixAlchemyParametersTemplate

Bases: SingleAlchemyParametersTemplate

Template for facefix alchemy parameters with all fields optional.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class FacefixAlchemyParametersTemplate(SingleAlchemyParametersTemplate):
    """Template for facefix alchemy parameters with all fields optional."""

    facefixer: KNOWN_FACEFIXERS | str | None = None

facefixer class-attribute instance-attribute

facefixer: KNOWN_FACEFIXERS | str | None = None

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

FacefixAlchemyParameters

Bases: SingleAlchemyParameters

Represents the parameters for a facefix alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class FacefixAlchemyParameters(SingleAlchemyParameters):
    """Represents the parameters for a facefix alchemy generation."""

    facefixer: KNOWN_FACEFIXERS | str

facefixer instance-attribute

facefixer: KNOWN_FACEFIXERS | str

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

form instance-attribute

form: KNOWN_ALCHEMY_FORMS | str

The form to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

InterrogateAlchemyParametersTemplate

Bases: SingleAlchemyParametersTemplate

Template for interrogate alchemy parameters with all fields optional.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class InterrogateAlchemyParametersTemplate(SingleAlchemyParametersTemplate):
    """Template for interrogate alchemy parameters with all fields optional."""

    interrogator: KNOWN_INTERROGATORS | str | None = None

interrogator class-attribute instance-attribute

interrogator: KNOWN_INTERROGATORS | str | None = None

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

InterrogateAlchemyParameters

Bases: SingleAlchemyParameters

Represents the parameters for an interrogation alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class InterrogateAlchemyParameters(SingleAlchemyParameters):
    """Represents the parameters for an interrogation alchemy generation."""

    interrogator: KNOWN_INTERROGATORS | str

interrogator instance-attribute

interrogator: KNOWN_INTERROGATORS | str

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

form instance-attribute

form: KNOWN_ALCHEMY_FORMS | str

The form to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

CaptionAlchemyParametersTemplate

Bases: SingleAlchemyParametersTemplate

Template for caption alchemy parameters with all fields optional.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class CaptionAlchemyParametersTemplate(SingleAlchemyParametersTemplate):
    """Template for caption alchemy parameters with all fields optional."""

    caption_model: KNOWN_CAPTION_MODELS | str | None = None

caption_model class-attribute instance-attribute

caption_model: KNOWN_CAPTION_MODELS | str | None = None

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

CaptionAlchemyParameters

Bases: SingleAlchemyParameters

Represents the parameters for a caption alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class CaptionAlchemyParameters(SingleAlchemyParameters):
    """Represents the parameters for a caption alchemy generation."""

    caption_model: KNOWN_CAPTION_MODELS | str

caption_model instance-attribute

caption_model: KNOWN_CAPTION_MODELS | str

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

form instance-attribute

form: KNOWN_ALCHEMY_FORMS | str

The form to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

NSFWAlchemyParametersTemplate

Bases: SingleAlchemyParametersTemplate

Template for NSFW alchemy parameters with all fields optional.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class NSFWAlchemyParametersTemplate(SingleAlchemyParametersTemplate):
    """Template for NSFW alchemy parameters with all fields optional."""

    nsfw_detector: KNOWN_NSFW_DETECTOR | str | None = None

nsfw_detector class-attribute instance-attribute

nsfw_detector: KNOWN_NSFW_DETECTOR | str | None = None

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id class-attribute instance-attribute

result_id: str | None = None

The generation ID to use for the generation.

form class-attribute instance-attribute

form: KNOWN_ALCHEMY_FORMS | str | None = None

The form to use for the generation.

source_image class-attribute instance-attribute

source_image: bytes | str | None = None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

to_parameters

to_parameters(
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy"
) -> SingleAlchemyParameters

Convert this template into concrete alchemy generation parameters.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def to_parameters(
    self,
    *,
    result_id: ID_TYPES | None = None,
    source_image: bytes | str | None = None,
    default_form: KNOWN_ALCHEMY_FORMS | str | None = None,
    allocator: ResultIdAllocator | None = None,
    seed: str = "alchemy",
) -> SingleAlchemyParameters:
    """Convert this template into concrete alchemy generation parameters."""
    overrides: dict[str, object] = {}
    if source_image is not None:
        overrides[ALCHEMY_PARAMETER_FIELDS.source_image] = source_image

    current_form = self.form
    if default_form is not None and current_form is None:
        overrides[ALCHEMY_PARAMETER_FIELDS.form] = default_form

    finalization = finalize_template_for_parameters(
        self,
        overrides=overrides,
        exclude_none=False,
        fingerprint_exclude_fields=(ALCHEMY_PARAMETER_FIELDS.result_id,),
    )

    resolved_result_id = resolve_result_id_from_payload(
        explicit_id=result_id,
        payload_value=finalization.payload.get(ALCHEMY_PARAMETER_FIELDS.result_id),
        allocator=allocator,
        seed=seed,
        fingerprint=finalization.fingerprint,
    )

    finalized_template = finalization.template.model_copy(
        update={ALCHEMY_PARAMETER_FIELDS.result_id: resolved_result_id},
    )

    return self._instantiate_alchemy_parameters(finalized_template)

NSFWAlchemyParameters

Bases: SingleAlchemyParameters

Represents the parameters for a NSFW alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class NSFWAlchemyParameters(SingleAlchemyParameters):
    """Represents the parameters for a NSFW alchemy generation."""

    nsfw_detector: KNOWN_NSFW_DETECTOR | str

nsfw_detector instance-attribute

nsfw_detector: KNOWN_NSFW_DETECTOR | str

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

result_id instance-attribute

result_id: str

The generation ID to use for the generation.

form instance-attribute

form: KNOWN_ALCHEMY_FORMS | str

The form to use for the generation.

source_image instance-attribute

source_image: bytes | str | None

The source image to use for the generation.

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return 1

AlchemyParameters

Bases: CompositeParametersBase

Represents the parameters for an alchemy generation.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
class AlchemyParameters(CompositeParametersBase):
    """Represents the parameters for an alchemy generation."""

    upscalers: list[UpscaleAlchemyParameters] | None = None
    """The upscale operations requested."""
    facefixers: list[FacefixAlchemyParameters] | None = None
    """The facefix operations requested."""
    interrogators: list[InterrogateAlchemyParameters] | None = None
    """The interrogation operations requested."""
    captions: list[CaptionAlchemyParameters] | None = None
    """The caption operations requested."""
    nsfw_detectors: list[NSFWAlchemyParameters] | None = None
    """The NSFW detection operations requested."""

    misc_post_processors: list[SingleAlchemyParameters] | None = None
    """Any other post-processing operations requested."""

    _all_alchemy_operations: list[SingleAlchemyParameters] | None = None
    """The list of all alchemy operations requested."""

    @property
    def all_alchemy_operations(self) -> list[SingleAlchemyParameters]:
        """Get all operations."""
        if self._all_alchemy_operations is not None:
            return self._all_alchemy_operations.copy()

        all_operations: list[SingleAlchemyParameters] = []
        if self.upscalers:
            all_operations.extend(self.upscalers)
        if self.facefixers:
            all_operations.extend(self.facefixers)
        if self.interrogators:
            all_operations.extend(self.interrogators)
        if self.captions:
            all_operations.extend(self.captions)
        if self.nsfw_detectors:
            all_operations.extend(self.nsfw_detectors)
        if self.misc_post_processors:
            all_operations.extend(self.misc_post_processors)

        self._all_alchemy_operations = all_operations

        return all_operations.copy()

    @override
    def get_number_expected_results(self) -> int:
        """Get the number of expected results."""
        return len(self.all_alchemy_operations)

upscalers class-attribute instance-attribute

upscalers: list[UpscaleAlchemyParameters] | None = None

The upscale operations requested.

facefixers class-attribute instance-attribute

facefixers: list[FacefixAlchemyParameters] | None = None

The facefix operations requested.

interrogators class-attribute instance-attribute

interrogators: list[InterrogateAlchemyParameters] | None = (
    None
)

The interrogation operations requested.

captions class-attribute instance-attribute

captions: list[CaptionAlchemyParameters] | None = None

The caption operations requested.

nsfw_detectors class-attribute instance-attribute

nsfw_detectors: list[NSFWAlchemyParameters] | None = None

The NSFW detection operations requested.

misc_post_processors class-attribute instance-attribute

misc_post_processors: (
    list[SingleAlchemyParameters] | None
) = None

Any other post-processing operations requested.

all_alchemy_operations property

all_alchemy_operations: list[SingleAlchemyParameters]

Get all operations.

SCHEMA_VERSION class-attribute

SCHEMA_VERSION: str = '1.0'

Most recent schema version for this payload.

LEGACY_SCHEMA_VERSION class-attribute

LEGACY_SCHEMA_VERSION: str = '1.0'

Oldest schema version supported for deserialization when unspecified.

schema_version class-attribute instance-attribute

schema_version: str = Field(
    default="",
    description="Schema version recorded when the payload was serialized.",
)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    use_attribute_docstrings=True,
    from_attributes=True,
    arbitrary_types_allowed=True,
)

underlying_generation_scheme class-attribute instance-attribute

underlying_generation_scheme: (
    UNDERLYING_GENERATION_SCHEME | None
) = None

The underlying method the generation uses to produce results.

Note that this refers only to the top-level generation itself. Component parameters may contain their own underlying generation schemes. For example, for stable diffusion image generation, this would always be MODEL even if some of the contained components use another scheme such as MODEL_FROM_SERVICE or NON_MODEL_ALGORITHM.

  • If the top-level generation is model-based, this should be set to MODEL.
  • If the top-level generation uses an outside service to produce results, this should be set to MODEL_FROM_SERVICE.
  • If the top-level generation does not use a generative model and instead uses a "traditional" algorithm, this should be set to NON_MODEL_ALGORITHM.

get_number_expected_results

get_number_expected_results() -> int

Get the number of expected results.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@override
def get_number_expected_results(self) -> int:
    """Get the number of expected results."""
    return len(self.all_alchemy_operations)

current_schema_version classmethod

current_schema_version() -> str

Return the canonical schema version for newly created instances.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def current_schema_version(cls) -> str:
    """Return the canonical schema version for newly created instances."""
    return cls.SCHEMA_VERSION

legacy_schema_version classmethod

legacy_schema_version() -> str

Return the version assumed for pre-metadata payloads.

Source code in horde_sdk/generation_parameters/generic/__init__.py
@classmethod
def legacy_schema_version(cls) -> str:
    """Return the version assumed for pre-metadata payloads."""
    return getattr(cls, "LEGACY_SCHEMA_VERSION", cls.SCHEMA_VERSION)

ResolverRule dataclass

Ordered rule binding a predicate to the concrete parameter model it selects.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
@dataclass(frozen=True)
class ResolverRule:
    """Ordered rule binding a predicate to the concrete parameter model it selects."""

    predicate: Predicate
    model: type[SingleAlchemyParameters]

predicate instance-attribute

predicate: Predicate

model instance-attribute

model: type[SingleAlchemyParameters]

__init__

__init__(
    predicate: Predicate,
    model: type[SingleAlchemyParameters],
) -> None

register_alchemy_parameter_rule

register_alchemy_parameter_rule(
    rule: ResolverRule, *, append: bool = True
) -> None

Register a resolver rule that may select a concrete alchemy parameter model.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def register_alchemy_parameter_rule(rule: ResolverRule, *, append: bool = True) -> None:
    """Register a resolver rule that may select a concrete alchemy parameter model."""
    if append:
        _ALCHEMY_PARAMETER_RULES.append(rule)
    else:
        _ALCHEMY_PARAMETER_RULES.insert(0, rule)

unregister_alchemy_parameter_rule

unregister_alchemy_parameter_rule(
    rule: ResolverRule,
) -> None

Remove a previously registered resolver rule.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def unregister_alchemy_parameter_rule(rule: ResolverRule) -> None:
    """Remove a previously registered resolver rule."""
    _ALCHEMY_PARAMETER_RULES.remove(rule)

resolve_alchemy_parameter_model

resolve_alchemy_parameter_model(
    payload: (
        Mapping[str, object]
        | SingleAlchemyParametersTemplate
    ),
) -> type[SingleAlchemyParameters]

Resolve the concrete alchemy parameter model for the supplied payload.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def resolve_alchemy_parameter_model(
    payload: Mapping[str, object] | SingleAlchemyParametersTemplate,
) -> type[SingleAlchemyParameters]:
    """Resolve the concrete alchemy parameter model for the supplied payload."""
    payload_mapping: Mapping[str, object]
    if isinstance(payload, CompositeParametersBase):
        payload_mapping = payload.model_dump(exclude_none=False)
    else:
        payload_mapping = payload
    for rule in _ALCHEMY_PARAMETER_RULES:
        if rule.predicate(payload_mapping):
            return rule.model
    return SingleAlchemyParameters

instantiate_alchemy_parameters

instantiate_alchemy_parameters(
    payload: (
        Mapping[str, object]
        | SingleAlchemyParametersTemplate
    ),
) -> SingleAlchemyParameters

Instantiate the resolved alchemy parameter model with the given payload.

Source code in horde_sdk/generation_parameters/alchemy/object_models.py
def instantiate_alchemy_parameters(
    payload: Mapping[str, object] | SingleAlchemyParametersTemplate,
) -> SingleAlchemyParameters:
    """Instantiate the resolved alchemy parameter model with the given payload."""
    model = resolve_alchemy_parameter_model(payload)
    if isinstance(payload, CompositeParametersBase):
        return model.model_validate(payload, from_attributes=True)
    return model(**dict(payload))