Skip to content

status

AlchemyUpscaleResult

Bases: HordeAPIData

Represents the result of an upscale job.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyUpscaleResult(HordeAPIData):
    """Represents the result of an upscale job."""

    upscaler_used: KNOWN_UPSCALERS | str
    """The upscaler used."""
    url: str
    """The URL of the upscaled image."""

upscaler_used instance-attribute

upscaler_used: KNOWN_UPSCALERS | str

The upscaler used.

url instance-attribute

url: str

The URL of the upscaled image.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyCaptionResult

Bases: HordeAPIData

Represents the result of a caption job.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyCaptionResult(HordeAPIData):
    """Represents the result of a caption job."""

    caption: str
    """The resulting caption of the image."""

caption instance-attribute

caption: str

The resulting caption of the image.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyNSFWResult

Bases: HordeAPIData

Represents the result of an NSFW evaluation.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyNSFWResult(HordeAPIData):
    """Represents the result of an NSFW evaluation."""

    nsfw: bool
    """Whether the image is likely to be NSFW."""

nsfw instance-attribute

nsfw: bool

Whether the image is likely to be NSFW.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyInterrogationResultItem

Bases: HordeAPIData

Represents an item in the result of an interrogation job.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyInterrogationResultItem(HordeAPIData):
    """Represents an item in the result of an interrogation job."""

    text: str
    """The text of the item."""
    confidence: float
    """The confidence of the item."""

text instance-attribute

text: str

The text of the item.

confidence instance-attribute

confidence: float

The confidence of the item.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyInterrogationDetails

Bases: HordeAPIData

The details of an interrogation job.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyInterrogationDetails(HordeAPIData):
    """The details of an interrogation job."""

    tags: list[AlchemyInterrogationResultItem]
    """The resulting similar tags of the image."""
    sites: list[AlchemyInterrogationResultItem]
    """The resulting similar sites of the image."""
    artists: list[AlchemyInterrogationResultItem]
    """The resulting similar artists of the image."""
    flavors: list[AlchemyInterrogationResultItem]
    """The resulting similar flavors of the image."""
    mediums: list[AlchemyInterrogationResultItem]
    """The resulting similar mediums of the image."""
    movements: list[AlchemyInterrogationResultItem]
    """The resulting similar movements of the image."""
    techniques: list[AlchemyInterrogationResultItem]
    """The resulting similar techniques of the image."""

tags instance-attribute

tags: list[AlchemyInterrogationResultItem]

The resulting similar tags of the image.

sites instance-attribute

sites: list[AlchemyInterrogationResultItem]

The resulting similar sites of the image.

artists instance-attribute

artists: list[AlchemyInterrogationResultItem]

The resulting similar artists of the image.

flavors instance-attribute

flavors: list[AlchemyInterrogationResultItem]

The resulting similar flavors of the image.

mediums instance-attribute

mediums: list[AlchemyInterrogationResultItem]

The resulting similar mediums of the image.

movements instance-attribute

movements: list[AlchemyInterrogationResultItem]

The resulting similar movements of the image.

techniques instance-attribute

techniques: list[AlchemyInterrogationResultItem]

The resulting similar techniques of the image.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyInterrogationResult

Bases: HordeAPIData

Represents the result of an interrogation job. Use the interrogation field for the details.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyInterrogationResult(HordeAPIData):
    """Represents the result of an interrogation job. Use the `interrogation` field for the details."""

    interrogation: AlchemyInterrogationDetails
    """The details of the interrogation."""

interrogation instance-attribute

interrogation: AlchemyInterrogationDetails

The details of the interrogation.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

AlchemyFormStatus

Bases: HordeAPIData

Represents the status of a form in an interrogation job.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyFormStatus(HordeAPIData):
    """Represents the status of a form in an interrogation job."""

    form: KNOWN_ALCHEMY_TYPES | str
    """The form type."""
    state: GENERATION_STATE
    """The state of the form."""
    result: AlchemyInterrogationDetails | AlchemyNSFWResult | AlchemyCaptionResult | AlchemyUpscaleResult | None = None
    """The result of the form."""

    @field_validator("form", mode="before")
    def validate_form(cls, v: str | KNOWN_ALCHEMY_TYPES) -> KNOWN_ALCHEMY_TYPES | str:
        """Ensure that the form is a known alchemy type."""
        if isinstance(v, KNOWN_ALCHEMY_TYPES):
            return v
        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

    @property
    def done(self) -> bool:
        """Return whether the form is done."""
        return self.state == "done"

    @field_validator("result", mode="before")
    def validate_result(
        cls,
        v: dict[str, object],
    ) -> dict[str, object] | None:
        """Ensure that the result is valid and convert it to the correct type, if possible."""
        if "additionalProp1" in v:
            logger.debug("Found additionalProp1 in result, this is a dummy result. Ignoring.")
            return None

        for key in list(v.keys()):
            if key in KNOWN_UPSCALERS.__members__:
                v["upscaler_used"] = KNOWN_UPSCALERS(key)
                v["url"] = v[key]
                del v[key]

        return v

form instance-attribute

form: KNOWN_ALCHEMY_TYPES | str

The form type.

state instance-attribute

state: GENERATION_STATE

The state of the form.

result class-attribute instance-attribute

result: (
    AlchemyInterrogationDetails
    | AlchemyNSFWResult
    | AlchemyCaptionResult
    | AlchemyUpscaleResult
    | None
) = None

The result of the form.

done property

done: bool

Return whether the form is done.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

validate_form

validate_form(
    v: str | KNOWN_ALCHEMY_TYPES,
) -> KNOWN_ALCHEMY_TYPES | str

Ensure that the form is a known alchemy type.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@field_validator("form", mode="before")
def validate_form(cls, v: str | KNOWN_ALCHEMY_TYPES) -> KNOWN_ALCHEMY_TYPES | str:
    """Ensure that the form is a known alchemy type."""
    if isinstance(v, KNOWN_ALCHEMY_TYPES):
        return v
    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

validate_result

validate_result(
    v: dict[str, object],
) -> dict[str, object] | None

Ensure that the result is valid and convert it to the correct type, if possible.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@field_validator("result", mode="before")
def validate_result(
    cls,
    v: dict[str, object],
) -> dict[str, object] | None:
    """Ensure that the result is valid and convert it to the correct type, if possible."""
    if "additionalProp1" in v:
        logger.debug("Found additionalProp1 in result, this is a dummy result. Ignoring.")
        return None

    for key in list(v.keys()):
        if key in KNOWN_UPSCALERS.__members__:
            v["upscaler_used"] = KNOWN_UPSCALERS(key)
            v["url"] = v[key]
            del v[key]

    return v

AlchemyStatusResponse

Bases: HordeResponseBaseModel, ResponseWithProgressMixin

Contains the status of an alchemy job and any completed work (if any).

Represents the data returned from the following endpoints and http status codes
  • /v2/interrogate/status/{id} | AlchemyStatusRequest [GET] -> 200
  • /v2/interrogate/status/{id} | AlchemyDeleteRequest [DELETE] -> 200

v2 API Model: InterrogationStatus

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyStatusResponse(HordeResponseBaseModel, ResponseWithProgressMixin):
    """Contains the status of an alchemy job and any completed work (if any).

    Represents the data returned from the following endpoints and http status codes:
        - /v2/interrogate/status/{id} | AlchemyStatusRequest [GET] -> 200
        - /v2/interrogate/status/{id} | AlchemyDeleteRequest [DELETE] -> 200

    v2 API Model: `InterrogationStatus`
    """

    state: GENERATION_STATE
    """The state of the job. See `GENERATION_STATE` for possible values."""
    forms: list[AlchemyFormStatus]
    """The status of each form in the job."""

    @property
    def all_interrogation_results(self) -> list[AlchemyInterrogationDetails]:
        """Return all completed interrogation results."""
        return [
            form.result for form in self.forms if form.done and isinstance(form.result, AlchemyInterrogationDetails)
        ]

    @property
    def all_nsfw_results(self) -> list[AlchemyNSFWResult]:
        """Return all completed nsfw results."""
        return [form.result for form in self.forms if form.done and isinstance(form.result, AlchemyNSFWResult)]

    @property
    def all_caption_results(self) -> list[AlchemyCaptionResult]:
        """Return all completed caption results."""
        return [form.result for form in self.forms if form.done and isinstance(form.result, AlchemyCaptionResult)]

    @property
    def all_upscale_results(self) -> list[AlchemyUpscaleResult]:
        """Return all completed upscale results."""
        return [form.result for form in self.forms if form.done and isinstance(form.result, AlchemyUpscaleResult)]

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return "InterrogationStatus"

    @override
    def is_job_complete(self, number_of_result_expected: int) -> bool:
        found_results = 0
        if not self.forms:
            return False
        for form in self.forms:
            if form.state != "done":
                return False
            found_results += 1
        return found_results == number_of_result_expected

    @override
    def is_job_possible(self) -> bool:
        return True  # FIXME

    @override
    @classmethod
    def is_final_follow_up(cls) -> bool:
        return True

    @override
    @classmethod
    def get_finalize_success_request_type(cls) -> None:
        return None

    def __eq__(self, other: object) -> bool:
        if not isinstance(other, AlchemyStatusResponse):
            return False
        return self.state == other.state and all(form in other.forms for form in self.forms)

    def __hash__(self) -> int:
        return hash((self.state, tuple(self.forms)))

state instance-attribute

state: GENERATION_STATE

The state of the job. See GENERATION_STATE for possible values.

forms instance-attribute

forms: list[AlchemyFormStatus]

The status of each form in the job.

all_interrogation_results property

all_interrogation_results: list[AlchemyInterrogationDetails]

Return all completed interrogation results.

all_nsfw_results property

all_nsfw_results: list[AlchemyNSFWResult]

Return all completed nsfw results.

all_caption_results property

all_caption_results: list[AlchemyCaptionResult]

Return all completed caption results.

all_upscale_results property

all_upscale_results: list[AlchemyUpscaleResult]

Return all completed upscale results.

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

time_constructed property

time_constructed: float

The time the model was constructed (in epoch time).

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return "InterrogationStatus"

is_job_complete

is_job_complete(number_of_result_expected: int) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
def is_job_complete(self, number_of_result_expected: int) -> bool:
    found_results = 0
    if not self.forms:
        return False
    for form in self.forms:
        if form.state != "done":
            return False
        found_results += 1
    return found_results == number_of_result_expected

is_job_possible

is_job_possible() -> bool
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
def is_job_possible(self) -> bool:
    return True  # FIXME

is_final_follow_up classmethod

is_final_follow_up() -> bool
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def is_final_follow_up(cls) -> bool:
    return True

get_finalize_success_request_type classmethod

get_finalize_success_request_type() -> None
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_finalize_success_request_type(cls) -> None:
    return None

__eq__

__eq__(other: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
def __eq__(self, other: object) -> bool:
    if not isinstance(other, AlchemyStatusResponse):
        return False
    return self.state == other.state and all(form in other.forms for form in self.forms)

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
def __hash__(self) -> int:
    return hash((self.state, tuple(self.forms)))

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]

Return a set of fields which should be redacted from logs.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    """Return a set of fields which should be redacted from logs."""
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

AlchemyStatusRequest

Bases: BaseAIHordeRequest, JobRequestMixin, APIKeyAllowedInRequestMixin

Poll for the status of an interrogation job, and retrieve any completed work.

Represents a GET request to the /v2/interrogate/status/{id} endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyStatusRequest(
    BaseAIHordeRequest,
    JobRequestMixin,
    APIKeyAllowedInRequestMixin,
):
    """Poll for the status of an interrogation job, and retrieve any completed work.

    Represents a GET request to the /v2/interrogate/status/{id} endpoint.
    """

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return None

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.GET

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_interrogate_status

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[AlchemyStatusResponse]:
        return AlchemyStatusResponse

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

apikey class-attribute instance-attribute

apikey: str | None = None

Defaults to ANON_API_KEY. See also .is_api_key_required()

id_ class-attribute instance-attribute

id_: GenerationID = Field(alias='id')

The UUID for this job. Use this to post the results in the future.

accept class-attribute instance-attribute

accept: GenericAcceptTypes = json

The 'accept' header field.

client_agent class-attribute instance-attribute

client_agent: str = Field(
    default=default_bridge_agent_string,
    alias="Client-Agent",
)

The requesting client's agent. You should set this to reflect the name, version and contact information for your client.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return None

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_interrogate_status

get_default_success_response_type classmethod

get_default_success_response_type() -> (
    type[AlchemyStatusResponse]
)
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[AlchemyStatusResponse]:
    return AlchemyStatusResponse

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]
Source code in horde_sdk/generic_api/apimodels.py
@override
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

is_api_key_required classmethod

is_api_key_required() -> bool

Return whether this endpoint requires an API key.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def is_api_key_required(cls) -> bool:
    """Return whether this endpoint requires an API key."""
    return True

validate_api_key_length

validate_api_key_length(v: str) -> str

Validate that the API key is the correct length, or is the special ANON_API_KEY.

Source code in horde_sdk/generic_api/apimodels.py
@field_validator("apikey", mode="before")
def validate_api_key_length(cls, v: str) -> str:
    """Validate that the API key is the correct length, or is the special ANON_API_KEY."""
    if v is None:
        return ANON_API_KEY
    if v == ANON_API_KEY:
        return v
    if len(v) == 36:
        try:
            uuid.UUID(v)
            return v
        except ValueError as e:
            raise ValueError("API key must be a valid UUID") from e
        return v
    if len(v) != 22:
        raise ValueError("API key must be 22 characters long")
    return v

validate_id

validate_id(v: str | GenerationID) -> GenerationID | str

Ensure that the job ID is not empty.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("id_", mode="before")
def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
    """Ensure that the job ID is not empty."""
    if isinstance(v, str) and v == "":
        logger.warning("Job ID is empty")
        return GenerationID(root=uuid.uuid4())

    return v

__eq__

__eq__(__value: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __eq__(self, __value: object) -> bool:
    if isinstance(__value, JobRequestMixin):
        return self.id_ == __value.id_
    return False

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __hash__(self) -> int:
    return hash(JobRequestMixin.__name__) + hash(self.id_)

get_api_endpoint_url classmethod

get_api_endpoint_url() -> str

Return the endpoint URL, including the path to the specific API action defined by this object.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_api_endpoint_url(cls) -> str:
    """Return the endpoint URL, including the path to the specific API action defined by this object."""
    return url_with_path(base_url=cls.get_api_url(), path=cls.get_api_endpoint_subpath())

get_api_url classmethod

get_api_url() -> str
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_url(cls) -> str:
    return AI_HORDE_BASE_URL

get_success_status_response_pairs classmethod

get_success_status_response_pairs() -> (
    dict[HTTPStatusCode, type[HordeResponseTypes]]
)

Return a dict of HTTP status codes and the expected HordeResponse.

Defaults to {HTTPStatusCode.OK: cls.get_expected_response_type()}, but may be overridden to support other status codes.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_success_status_response_pairs(
    cls,
) -> dict[HTTPStatusCode, type[HordeResponseTypes]]:
    """Return a dict of HTTP status codes and the expected `HordeResponse`.

    Defaults to `{HTTPStatusCode.OK: cls.get_expected_response_type()}`, but may be overridden to support other
    status codes.
    """
    return {HTTPStatusCode.OK: cls.get_default_success_response_type()}

get_header_fields classmethod

get_header_fields() -> list[str]

Return a list of field names from this request object that should be sent as header fields.

This is in addition to GenericHeaderFields's values, and possibly the API specific class which inherits from GenericHeaderFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_header_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as header fields.

    This is in addition to `GenericHeaderFields`'s values, and possibly the API specific class
    which inherits from `GenericHeaderFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_query_fields classmethod

get_query_fields() -> list[str]

Return a list of field names from this request object that should be sent as query parameters.

This is in addition to GenericQueryFields's values, and possibly the API specific class which inherits from GenericQueryFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_query_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as query parameters.

    This is in addition to `GenericQueryFields`'s values, and possibly the API specific class
    which inherits from `GenericQueryFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_number_of_results_expected

get_number_of_results_expected() -> int

Return the number of (job) results expected from this request.

Defaults to 1, but may be overridden to dynamically change the number of results expected.

This is factored into context management; if the number of results expected is not met, the job is considered unhandled on an exception and followed up on to attempt to close it.

Source code in horde_sdk/generic_api/apimodels.py
def get_number_of_results_expected(self) -> int:
    """Return the number of (job) results expected from this request.

    Defaults to `1`, but may be overridden to dynamically change the number of results expected.

    This is factored into context management; if the number of results expected is not met, the job is considered
    unhandled on an exception and followed up on to attempt to close it.
    """
    return 1

get_requires_follow_up

get_requires_follow_up() -> bool

Return whether this request requires a follow up request(s).

Returns:

  • bool ( bool ) –

    Whether this request requires a follow up request to close the job on the server.

Source code in horde_sdk/generic_api/apimodels.py
def get_requires_follow_up(self) -> bool:
    """Return whether this request requires a follow up request(s).

    Returns:
        bool: Whether this request requires a follow up request to close the job on the server.
    """
    for response_type in self.get_success_status_response_pairs().values():
        if issubclass(response_type, ResponseRequiringFollowUpMixin):
            return True
    return False

AlchemyDeleteRequest

Bases: BaseAIHordeRequest, JobRequestMixin

Cancel an in-progress interrogation job.

Represents a DELETE request to the /v2/interrogate/status/{id} endpoint.

Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
class AlchemyDeleteRequest(
    BaseAIHordeRequest,
    JobRequestMixin,
):
    """Cancel an in-progress interrogation job.

    Represents a DELETE request to the /v2/interrogate/status/{id} endpoint.
    """

    @override
    @classmethod
    def get_api_model_name(cls) -> str | None:
        return None

    @override
    @classmethod
    def get_http_method(cls) -> HTTPMethod:
        return HTTPMethod.DELETE

    @override
    @classmethod
    def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
        return AI_HORDE_API_ENDPOINT_SUBPATH.v2_interrogate_status

    @override
    @classmethod
    def get_default_success_response_type(cls) -> type[AlchemyStatusResponse]:
        return AlchemyStatusResponse

model_config class-attribute instance-attribute

model_config = get_default_frozen_model_config_dict()

id_ class-attribute instance-attribute

id_: GenerationID = Field(alias='id')

The UUID for this job. Use this to post the results in the future.

accept class-attribute instance-attribute

accept: GenericAcceptTypes = json

The 'accept' header field.

client_agent class-attribute instance-attribute

client_agent: str = Field(
    default=default_bridge_agent_string,
    alias="Client-Agent",
)

The requesting client's agent. You should set this to reflect the name, version and contact information for your client.

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_api_model_name(cls) -> str | None:
    return None

get_http_method classmethod

get_http_method() -> HTTPMethod
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.DELETE

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> AI_HORDE_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> AI_HORDE_API_ENDPOINT_SUBPATH:
    return AI_HORDE_API_ENDPOINT_SUBPATH.v2_interrogate_status

get_default_success_response_type classmethod

get_default_success_response_type() -> (
    type[AlchemyStatusResponse]
)
Source code in horde_sdk/ai_horde_api/apimodels/alchemy/status.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[AlchemyStatusResponse]:
    return AlchemyStatusResponse

validate_id

validate_id(v: str | GenerationID) -> GenerationID | str

Ensure that the job ID is not empty.

Source code in horde_sdk/ai_horde_api/apimodels/base.py
@field_validator("id_", mode="before")
def validate_id(cls, v: str | GenerationID) -> GenerationID | str:
    """Ensure that the job ID is not empty."""
    if isinstance(v, str) and v == "":
        logger.warning("Job ID is empty")
        return GenerationID(root=uuid.uuid4())

    return v

__eq__

__eq__(__value: object) -> bool
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __eq__(self, __value: object) -> bool:
    if isinstance(__value, JobRequestMixin):
        return self.id_ == __value.id_
    return False

__hash__

__hash__() -> int
Source code in horde_sdk/ai_horde_api/apimodels/base.py
def __hash__(self) -> int:
    return hash(JobRequestMixin.__name__) + hash(self.id_)

get_sensitive_fields classmethod

get_sensitive_fields() -> set[str]
Source code in horde_sdk/generic_api/apimodels.py
@override
@classmethod
def get_sensitive_fields(cls) -> set[str]:
    return {"apikey"}

get_extra_fields_to_exclude_from_log

get_extra_fields_to_exclude_from_log() -> set[str]

Return an additional set of fields to exclude from the log_safe_model_dump method.

Source code in horde_sdk/generic_api/apimodels.py
def get_extra_fields_to_exclude_from_log(self) -> set[str]:
    """Return an additional set of fields to exclude from the log_safe_model_dump method."""
    return set()

log_safe_model_dump

log_safe_model_dump(
    extra_exclude: set[str] | None = None,
) -> dict[Any, Any]

Return a dict of the model's fields, with any sensitive fields redacted.

Source code in horde_sdk/generic_api/apimodels.py
def log_safe_model_dump(self, extra_exclude: set[str] | None = None) -> dict[Any, Any]:
    """Return a dict of the model's fields, with any sensitive fields redacted."""
    if extra_exclude is None:
        extra_exclude = set()

    if hasattr(self, "model_dump"):
        return self.model_dump(  # type: ignore
            exclude=self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude,
        )

    logger.warning("Model does not have a model_dump method. Using python native class compatible method.")
    logger.debug(
        "Generally this should not be relied upon. If you're seeing this and you're a developer for the SDK, "
        "consider using pydantic models instead.",
    )
    # Its not a pydantic model, use python native class compatible method
    return {
        key: getattr(self, key)
        for key in self.__dict__
        if key not in self.get_sensitive_fields() | self.get_extra_fields_to_exclude_from_log() | extra_exclude
    }

get_api_endpoint_url classmethod

get_api_endpoint_url() -> str

Return the endpoint URL, including the path to the specific API action defined by this object.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_api_endpoint_url(cls) -> str:
    """Return the endpoint URL, including the path to the specific API action defined by this object."""
    return url_with_path(base_url=cls.get_api_url(), path=cls.get_api_endpoint_subpath())

get_api_url classmethod

get_api_url() -> str
Source code in horde_sdk/ai_horde_api/apimodels/base.py
@override
@classmethod
def get_api_url(cls) -> str:
    return AI_HORDE_BASE_URL

get_success_status_response_pairs classmethod

get_success_status_response_pairs() -> (
    dict[HTTPStatusCode, type[HordeResponseTypes]]
)

Return a dict of HTTP status codes and the expected HordeResponse.

Defaults to {HTTPStatusCode.OK: cls.get_expected_response_type()}, but may be overridden to support other status codes.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_success_status_response_pairs(
    cls,
) -> dict[HTTPStatusCode, type[HordeResponseTypes]]:
    """Return a dict of HTTP status codes and the expected `HordeResponse`.

    Defaults to `{HTTPStatusCode.OK: cls.get_expected_response_type()}`, but may be overridden to support other
    status codes.
    """
    return {HTTPStatusCode.OK: cls.get_default_success_response_type()}

get_header_fields classmethod

get_header_fields() -> list[str]

Return a list of field names from this request object that should be sent as header fields.

This is in addition to GenericHeaderFields's values, and possibly the API specific class which inherits from GenericHeaderFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_header_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as header fields.

    This is in addition to `GenericHeaderFields`'s values, and possibly the API specific class
    which inherits from `GenericHeaderFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_query_fields classmethod

get_query_fields() -> list[str]

Return a list of field names from this request object that should be sent as query parameters.

This is in addition to GenericQueryFields's values, and possibly the API specific class which inherits from GenericQueryFields, typically found in the horde_sdk.<api_name>_api.metadata module.

Source code in horde_sdk/generic_api/apimodels.py
@classmethod
def get_query_fields(cls) -> list[str]:
    """Return a list of field names from this request object that should be sent as query parameters.

    This is in addition to `GenericQueryFields`'s values, and possibly the API specific class
    which inherits from `GenericQueryFields`, typically found in the `horde_sdk.<api_name>_api.metadata` module.
    """
    return []

get_number_of_results_expected

get_number_of_results_expected() -> int

Return the number of (job) results expected from this request.

Defaults to 1, but may be overridden to dynamically change the number of results expected.

This is factored into context management; if the number of results expected is not met, the job is considered unhandled on an exception and followed up on to attempt to close it.

Source code in horde_sdk/generic_api/apimodels.py
def get_number_of_results_expected(self) -> int:
    """Return the number of (job) results expected from this request.

    Defaults to `1`, but may be overridden to dynamically change the number of results expected.

    This is factored into context management; if the number of results expected is not met, the job is considered
    unhandled on an exception and followed up on to attempt to close it.
    """
    return 1

get_requires_follow_up

get_requires_follow_up() -> bool

Return whether this request requires a follow up request(s).

Returns:

  • bool ( bool ) –

    Whether this request requires a follow up request to close the job on the server.

Source code in horde_sdk/generic_api/apimodels.py
def get_requires_follow_up(self) -> bool:
    """Return whether this request requires a follow up request(s).

    Returns:
        bool: Whether this request requires a follow up request to close the job on the server.
    """
    for response_type in self.get_success_status_response_pairs().values():
        if issubclass(response_type, ResponseRequiringFollowUpMixin):
            return True
    return False