Skip to content

apimodels

Model definitions for AI Horde Ratings API.

__all__ module-attribute

__all__ = ['BaseImageRatingRecord', 'BaseRatingsAPIRequest', 'BaseSelectableReturnTypeRequest', 'HordeRequestImageSpecific', 'ImageRatingResponseSubRecord', 'ImageRatingsComparisonTypes', 'ImageRatingsFilterableRequestBase', 'ImageRatingsRequest', 'ImageRatingsResponse', 'SelectableReturnFormats', 'UserCheckRequest', 'UserCheckResponse', 'UserRatingsRequest', 'UserRatingsResponse', 'UserRatingsResponseSubRecord', 'UserValidateRequest', 'UserValidateResponse', 'UserValidateResponseRecord']

BaseRatingsAPIRequest

Bases: HordeRequest

Base class for all requests to the AI Horde Ratings API.

Source code in horde_sdk/ratings_api/apimodels.py
class BaseRatingsAPIRequest(HordeRequest):
    """Base class for all requests to the AI Horde Ratings API."""

    @override
    @classmethod
    def get_api_url(cls) -> str:
        return RATING_API_BASE_URL

get_api_url classmethod

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

BaseImageRatingRecord

Bases: BaseModel

The information about any image rating result.

Source code in horde_sdk/ratings_api/apimodels.py
class BaseImageRatingRecord(BaseModel):
    """The information about any image rating result."""

    image: str
    """The URL to the image."""
    rating: int
    """The aesthetic rating the user gave."""
    artifacts: int | None
    """The quality ('artifact') rating the user gave."""
    average: float
    """The average rating that all users have given this image."""
    times_rated: int
    """The number of total ratings this image has received."""

image instance-attribute

image: str

The URL to the image.

rating instance-attribute

rating: int

The aesthetic rating the user gave.

artifacts instance-attribute

artifacts: int | None

The quality ('artifact') rating the user gave.

average instance-attribute

average: float

The average rating that all users have given this image.

times_rated instance-attribute

times_rated: int

The number of total ratings this image has received.

ImageRatingResponseSubRecord

Bases: BaseModel

A single sub-record in a response from the /v1/image/ratings endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class ImageRatingResponseSubRecord(BaseModel):
    """A single sub-record in a response from the `/v1/image/ratings` endpoint."""

    username: str
    rating: int
    artifacts: int | None

username instance-attribute

username: str

rating instance-attribute

rating: int

artifacts instance-attribute

artifacts: int | None

ImageRatingsResponse

Bases: HordeResponseBaseModel

The representation of the full response from /v1/image/ratings.

Source code in horde_sdk/ratings_api/apimodels.py
class ImageRatingsResponse(HordeResponseBaseModel):
    """The representation of the full response from `/v1/image/ratings`."""

    total: int
    image: str
    image_id: uuid.UUID
    average: float
    times_rated: int
    ratings: list[ImageRatingResponseSubRecord]

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

total instance-attribute

total: int

image instance-attribute

image: str

image_id instance-attribute

image_id: UUID

average instance-attribute

average: float

times_rated instance-attribute

times_rated: int

ratings instance-attribute

ratings: list[ImageRatingResponseSubRecord]

get_api_model_name classmethod

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

UserRatingsResponseSubRecord

Bases: BaseImageRatingRecord

A single sub-record in a response from the /v1/user/ratings endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserRatingsResponseSubRecord(BaseImageRatingRecord):
    """A single sub-record in a response from the `/v1/user/ratings` endpoint."""

    username: str
    """The name of the user in format `name#1234`."""

username instance-attribute

username: str

The name of the user in format name#1234.

UserRatingsResponse

Bases: HordeResponseBaseModel

The representation of the full response from /v1/user/ratings.

Source code in horde_sdk/ratings_api/apimodels.py
class UserRatingsResponse(HordeResponseBaseModel):
    """The representation of the full response from `/v1/user/ratings`."""

    total: int
    """The total number of records in this response."""
    ratings: list[UserRatingsResponseSubRecord]
    """A `list` of all records returned."""

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

total instance-attribute

total: int

The total number of records in this response.

ratings instance-attribute

ratings: list[UserRatingsResponseSubRecord]

A list of all records returned.

get_api_model_name classmethod

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

UserValidateResponseRecord

Bases: BaseImageRatingRecord

A single sub-record in a response from the /v1/validate/{user_id} endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserValidateResponseRecord(BaseImageRatingRecord):
    """A single sub-record in a response from the `/v1/validate/{user_id}` endpoint."""

UserValidateResponse

Bases: HordeResponseBaseModel

The representation of the full response from /v1/validate/{user_id}.

Source code in horde_sdk/ratings_api/apimodels.py
class UserValidateResponse(HordeResponseBaseModel):
    """The representation of the full response from `/v1/validate/{user_id}`."""

    total: int
    """The total number of records in this response."""
    ratings: list[UserValidateResponseRecord]
    """A `list` of all records returned."""

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

total instance-attribute

total: int

The total number of records in this response.

ratings instance-attribute

ratings: list[UserValidateResponseRecord]

A list of all records returned.

get_api_model_name classmethod

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

UserCheckResponse

Bases: HordeResponseBaseModel

A single record from the /v1/user/check/ endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserCheckResponse(HordeResponseBaseModel):
    """A single record from the `/v1/user/check/` endpoint."""

    ratings_in_timeframe: int
    """The number of ratings this user submitted in the timeframe."""
    ratings_per_minute_in_timeframe: float
    """The average number of ratings per minute."""
    ratings_past_three_hours: int
    """The average number of ratings in the three hours prior to the request."""
    ratings_per_minute_for_past_three_hours: float
    """The average number of ratings per minute in the three hours prior to the request."""
    suspect_divergences: int
    """The number of instances of this user's rating not being within the criteria."""
    captchas_failed: int
    """The number of captchas failed by this user."""

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

ratings_in_timeframe instance-attribute

ratings_in_timeframe: int

The number of ratings this user submitted in the timeframe.

ratings_per_minute_in_timeframe instance-attribute

ratings_per_minute_in_timeframe: float

The average number of ratings per minute.

ratings_past_three_hours instance-attribute

ratings_past_three_hours: int

The average number of ratings in the three hours prior to the request.

ratings_per_minute_for_past_three_hours instance-attribute

ratings_per_minute_for_past_three_hours: float

The average number of ratings per minute in the three hours prior to the request.

suspect_divergences instance-attribute

suspect_divergences: int

The number of instances of this user's rating not being within the criteria.

captchas_failed instance-attribute

captchas_failed: int

The number of captchas failed by this user.

get_api_model_name classmethod

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

HordeRequestImageSpecific

Bases: BaseModel

Represents the minimum for any request specifying a specific user to the API.

Source code in horde_sdk/ratings_api/apimodels.py
class HordeRequestImageSpecific(BaseModel):
    """Represents the minimum for any request specifying a specific user to the API."""

    image_id: uuid.UUID
    """The UUID of the image."""

image_id instance-attribute

image_id: UUID

The UUID of the image.

SelectableReturnFormats

Bases: StrEnum

Formats the API supports returning data.

Source code in horde_sdk/ratings_api/apimodels.py
class SelectableReturnFormats(StrEnum):
    """Formats the API supports returning data."""

    html = auto()
    json = auto()

html class-attribute instance-attribute

html = auto()

json class-attribute instance-attribute

json = auto()

BaseSelectableReturnTypeRequest

Bases: BaseModel

Mix-in class to describe an endpoint for which you can select the return data format.

Source code in horde_sdk/ratings_api/apimodels.py
class BaseSelectableReturnTypeRequest(BaseModel):
    """Mix-in class to describe an endpoint for which you can select the return data format."""

    format: SelectableReturnFormats
    """The format to request the response payload in, typically json."""

format instance-attribute

format: SelectableReturnFormats

The format to request the response payload in, typically json.

ImageRatingsRequest

Bases: BaseRatingsAPIRequest, APIKeyAllowedInRequestMixin, BaseSelectableReturnTypeRequest

Represents the data needed to make a request to the /v1/image/ratings/{image_id} endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class ImageRatingsRequest(
    BaseRatingsAPIRequest,
    APIKeyAllowedInRequestMixin,
    BaseSelectableReturnTypeRequest,
):
    """Represents the data needed to make a request to the `/v1/image/ratings/{image_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) -> RATING_API_ENDPOINT_SUBPATH:
        return RATING_API_ENDPOINT_SUBPATH.v1_image_ratings

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

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ratings_api/apimodels.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/ratings_api/apimodels.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> RATING_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> RATING_API_ENDPOINT_SUBPATH:
    return RATING_API_ENDPOINT_SUBPATH.v1_image_ratings

get_default_success_response_type classmethod

get_default_success_response_type() -> type[ImageRatingsResponse]
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[ImageRatingsResponse]:
    return ImageRatingsResponse

ImageRatingsComparisonTypes

Bases: StrEnum

Ways the API supports selecting a rating range.

Source code in horde_sdk/ratings_api/apimodels.py
class ImageRatingsComparisonTypes(StrEnum):
    """Ways the API supports selecting a rating range."""

    greater_than_equal = "ge"
    less_than_equal = "le"
    equal = "eq"

greater_than_equal class-attribute instance-attribute

greater_than_equal = 'ge'

less_than_equal class-attribute instance-attribute

less_than_equal = 'le'

equal class-attribute instance-attribute

equal = 'eq'

ImageRatingsFilterableRequestBase

Bases: BaseSelectableReturnTypeRequest

Generically, data the API requires to filter results prior and how to return them.

Source code in horde_sdk/ratings_api/apimodels.py
class ImageRatingsFilterableRequestBase(BaseSelectableReturnTypeRequest):
    """Generically, data the API requires to filter results prior and how to return them."""

    rating: int | None
    """The target rating, which will be compared by `rating_comparison`."""
    rating_comparison: ImageRatingsComparisonTypes | None
    """The way the `rating` will be compared. See `ImageRatingsComparisonTypes`."""
    artifacts: int | None = None
    """The target artifact rating, which will be compared by `artifacts_comparison`."""
    artifacts_comparison: ImageRatingsComparisonTypes | None = None
    """The way the `artifacts` will be compared. See `ImageRatingsComparisonTypes`."""
    min_ratings: int | None

rating instance-attribute

rating: int | None

The target rating, which will be compared by rating_comparison.

rating_comparison instance-attribute

rating_comparison: ImageRatingsComparisonTypes | None

The way the rating will be compared. See ImageRatingsComparisonTypes.

artifacts class-attribute instance-attribute

artifacts: int | None = None

The target artifact rating, which will be compared by artifacts_comparison.

artifacts_comparison class-attribute instance-attribute

artifacts_comparison: ImageRatingsComparisonTypes | None = None

The way the artifacts will be compared. See ImageRatingsComparisonTypes.

min_ratings instance-attribute

min_ratings: int | None

UserValidateRequest

Bases: BaseRatingsAPIRequest, APIKeyAllowedInRequestMixin, RequestSpecifiesUserIDMixin, ImageRatingsFilterableRequestBase

Represents the data needed to make a request to the /v1/user/validate/{user_id} endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserValidateRequest(
    BaseRatingsAPIRequest,
    APIKeyAllowedInRequestMixin,
    RequestSpecifiesUserIDMixin,
    ImageRatingsFilterableRequestBase,
):
    """Represents the data needed to make a request to the `/v1/user/validate/{user_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) -> RATING_API_ENDPOINT_SUBPATH:
        return RATING_API_ENDPOINT_SUBPATH.v1_user_validate

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

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ratings_api/apimodels.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/ratings_api/apimodels.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> RATING_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> RATING_API_ENDPOINT_SUBPATH:
    return RATING_API_ENDPOINT_SUBPATH.v1_user_validate

get_default_success_response_type classmethod

get_default_success_response_type() -> type[UserValidateResponse]
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[UserValidateResponse]:
    return UserValidateResponse

UserCheckRequest

Bases: BaseRatingsAPIRequest, APIKeyAllowedInRequestMixin, RequestSpecifiesUserIDMixin

Represents the data needed to make a request to the /v1/user/check/ endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserCheckRequest(
    BaseRatingsAPIRequest,
    APIKeyAllowedInRequestMixin,
    RequestSpecifiesUserIDMixin,
):
    """Represents the data needed to make a request to the `/v1/user/check/` endpoint."""

    minutes: int = Field(ge=1)
    divergence: int = Field(ge=0)

    @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) -> RATING_API_ENDPOINT_SUBPATH:
        return RATING_API_ENDPOINT_SUBPATH.v1_user_check

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

minutes class-attribute instance-attribute

minutes: int = Field(ge=1)

divergence class-attribute instance-attribute

divergence: int = Field(ge=0)

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ratings_api/apimodels.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/ratings_api/apimodels.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> RATING_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> RATING_API_ENDPOINT_SUBPATH:
    return RATING_API_ENDPOINT_SUBPATH.v1_user_check

get_default_success_response_type classmethod

get_default_success_response_type() -> type[UserCheckResponse]
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[UserCheckResponse]:
    return UserCheckResponse

UserRatingsRequest

Bases: BaseRatingsAPIRequest, APIKeyAllowedInRequestMixin, ImageRatingsFilterableRequestBase

Represents the data needed to make a request to the /v1/user/ratings/ endpoint.

Source code in horde_sdk/ratings_api/apimodels.py
class UserRatingsRequest(
    BaseRatingsAPIRequest,
    APIKeyAllowedInRequestMixin,
    ImageRatingsFilterableRequestBase,
):
    """Represents the data needed to make a request to the `/v1/user/ratings/` endpoint."""

    limit: int
    offset: int = 0
    diverge: int | None

    @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) -> RATING_API_ENDPOINT_SUBPATH:
        return RATING_API_ENDPOINT_SUBPATH.v1_user_ratings

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

limit instance-attribute

limit: int

offset class-attribute instance-attribute

offset: int = 0

diverge instance-attribute

diverge: int | None

get_api_model_name classmethod

get_api_model_name() -> str | None
Source code in horde_sdk/ratings_api/apimodels.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/ratings_api/apimodels.py
@override
@classmethod
def get_http_method(cls) -> HTTPMethod:
    return HTTPMethod.GET

get_api_endpoint_subpath classmethod

get_api_endpoint_subpath() -> RATING_API_ENDPOINT_SUBPATH
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_api_endpoint_subpath(cls) -> RATING_API_ENDPOINT_SUBPATH:
    return RATING_API_ENDPOINT_SUBPATH.v1_user_ratings

get_default_success_response_type classmethod

get_default_success_response_type() -> type[UserRatingsResponse]
Source code in horde_sdk/ratings_api/apimodels.py
@override
@classmethod
def get_default_success_response_type(cls) -> type[UserRatingsResponse]:
    return UserRatingsResponse