Skip to content

Commit

Permalink
feat: support remix
Browse files Browse the repository at this point in the history
feat: Support for extra_source_images
fix: Run scripts to update API ref
feat: added missing keys
fix: make `ImageGenerateAsyncResponse` hashable
  • Loading branch information
db0 authored and tazlin committed Mar 23, 2024
1 parent 702f0eb commit f90cd73
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 4 deletions.
3 changes: 3 additions & 0 deletions codegen/ai_horde_codegen_10072023.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,9 @@ class UserKudosDetails(BaseModel):
)
gifted: float | None = Field(0, description="The amount of Kudos this user has given to other users.")
received: float | None = Field(0, description="The amount of Kudos this user has been given by other users.")
donated: float | None = Field(
0, description="The amount of Kudos this user has donated to support education accounts."
)
recurring: float | None = Field(
0,
description="The amount of Kudos this user has received from recurring rewards.",
Expand Down
4 changes: 4 additions & 0 deletions docs/request_field_names_and_descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
[
"source_mask",
null
],
[
"extra_source_images",
null
]
],
"ImageGenerateCheckRequest": [
Expand Down
12 changes: 12 additions & 0 deletions docs/response_field_names_and_descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@
"vpn",
"(Privileged) This user has been given the VPN role."
],
[
"education",
"This user has been given education VPN role."
],
[
"worker_count",
"How many workers this user has created (active or inactive)."
Expand Down Expand Up @@ -261,6 +265,10 @@
[
"kudos",
null
],
[
"warnings",
null
]
],
"ImageGenerateCheckResponse": [
Expand Down Expand Up @@ -338,6 +346,10 @@
"source_mask",
null
],
[
"extra_source_images",
null
],
[
"r2_upload",
null
Expand Down
8 changes: 7 additions & 1 deletion horde_sdk/ai_horde_api/apimodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
AlchemyStatusResponse,
AlchemyUpscaleResult,
)
from horde_sdk.ai_horde_api.apimodels.base import GenMetadataEntry, LorasPayloadEntry, TIPayloadEntry
from horde_sdk.ai_horde_api.apimodels.base import (
ExtraSourceImageEntry,
GenMetadataEntry,
LorasPayloadEntry,
TIPayloadEntry,
)
from horde_sdk.ai_horde_api.apimodels.generate._async import (
ImageGenerateAsyncDryRunResponse,
ImageGenerateAsyncRequest,
Expand Down Expand Up @@ -112,6 +117,7 @@
"StatsModelsResponse",
"StatsModelsTimeframe",
"TIPayloadEntry",
"ExtraSourceImageEntry",
"GenMetadataEntry",
"UsageDetails",
"UserAmountRecords",
Expand Down
10 changes: 10 additions & 0 deletions horde_sdk/ai_horde_api/apimodels/_find_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class UserKudosDetails(HordeAPIDataObject):
)
gifted: float | None = Field(0, description="The amount of Kudos this user has given to other users.")
received: float | None = Field(0, description="The amount of Kudos this user has been given by other users.")
donated: float | None = Field(
0,
description="The amount of Kudos this user has donated to support education accounts.",
)
recurring: float | None = Field(
0,
description="The amount of Kudos this user has received from recurring rewards.",
Expand Down Expand Up @@ -166,6 +170,12 @@ def get_api_model_name(cls) -> str | None:
examples=[False],
)
"""(Privileged) This user has been given the VPN role."""
education: bool | None = Field(
default=None,
description="This user has been given education VPN role.",
examples=[False],
)
"""(This user has been given the education role."""
worker_count: int | None = Field(
default=None,
description="How many workers this user has created (active or inactive).",
Expand Down
24 changes: 24 additions & 0 deletions horde_sdk/ai_horde_api/apimodels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@ def strength_only_if_inject_ti(self) -> TIPayloadEntry:
return self


class ExtraSourceImageEntry(HordeAPIDataObject):
"""Represents a single extra source image.
v2 API Model: `ExtraSourceImage`
"""

image: str = Field(min_length=1)
"""The URL of the image to download."""
strength: float = Field(default=1, ge=-5, le=5)
"""The strength to apply to this image on various operations."""


class SingleWarningEntry(HordeAPIDataObject):
"""Represents a single warning.
v2 API Model: `RequestSingleWarning`
"""

code: str = Field(min_length=1)
"""The code uniquely identifying this warning."""
message: str = Field(min_length=1)
"""The human-readable description of this warning"""


class ImageGenerateParamMixin(HordeAPIDataObject):
"""Mix-in class of some of the data included in a request to the `/v2/generate/async` endpoint.
Expand Down
11 changes: 11 additions & 0 deletions horde_sdk/ai_horde_api/apimodels/generate/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

from horde_sdk.ai_horde_api.apimodels.base import (
BaseAIHordeRequest,
ExtraSourceImageEntry,
ImageGenerateParamMixin,
JobResponseMixin,
SingleWarningEntry,
)
from horde_sdk.ai_horde_api.apimodels.generate._check import ImageGenerateCheckRequest
from horde_sdk.ai_horde_api.apimodels.generate._status import DeleteImageGenerateRequest, ImageGenerateStatusRequest
Expand Down Expand Up @@ -36,6 +38,7 @@ class ImageGenerateAsyncResponse(

"""The UUID for this image generation."""
kudos: float
warnings: list[SingleWarningEntry]

@override
def get_follow_up_returned_params(self, *, as_python_field_name: bool = False) -> list[dict[str, object]]:
Expand Down Expand Up @@ -64,6 +67,12 @@ def get_follow_up_failure_cleanup_request_type(cls) -> type[DeleteImageGenerateR
def get_api_model_name(cls) -> str | None:
return "RequestAsync"

def __hash__(self) -> int:
return hash(self.id_)

def __eq__(self, __value: object) -> bool:
return isinstance(__value, ImageGenerateAsyncResponse) and self.id_ == __value.id_


class ImageGenerateAsyncDryRunResponse(HordeResponseBaseModel):
kudos: float
Expand Down Expand Up @@ -125,6 +134,8 @@ class ImageGenerateAsyncRequest(
source_image: str | None = None
source_processing: KNOWN_SOURCE_PROCESSING = KNOWN_SOURCE_PROCESSING.txt2img
source_mask: str | None = None
extra_source_images: list[ExtraSourceImageEntry] | None = None
"""Additional uploaded images which can be used for further operations."""

@model_validator(mode="before")
def validate_censor_nsfw(cls, values: dict) -> dict:
Expand Down
3 changes: 3 additions & 0 deletions horde_sdk/ai_horde_api/apimodels/generate/_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from horde_sdk.ai_horde_api.apimodels.base import (
BaseAIHordeRequest,
ExtraSourceImageEntry,
ImageGenerateParamMixin,
)
from horde_sdk.ai_horde_api.apimodels.generate._submit import ImageGenerationJobSubmitRequest
Expand Down Expand Up @@ -109,6 +110,8 @@ class ImageGenerateJobPopResponse(HordeResponseBaseModel, ResponseRequiringFollo
"""If img_processing is set to 'inpainting' or 'outpainting', this parameter can be optionally provided as the
mask of the areas to inpaint. If this arg is not passed, the inpainting/outpainting mask has to be embedded as
alpha channel."""
extra_source_images: list[ExtraSourceImageEntry] | None = None
"""Additional uploaded images which can be used for further operations."""
r2_upload: str | None = None
"""(Obsolete) The r2 upload link to use to upload this image."""
r2_uploads: list[str] | None = None
Expand Down
1 change: 1 addition & 0 deletions horde_sdk/ai_horde_api/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class METADATA_TYPE(StrEnum):
censorship = auto()
source_image = auto()
source_mask = auto()
extra_source_images = auto()
batch_index = auto()


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"prompt": "a",
"params": {
"sampler_name": "k_dpmpp_2m",
"sampler_name": "DDIM",
"cfg_scale": 7.5,
"denoising_strength": 0.75,
"seed": "The little seed that could",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
""
],
"min_p": 0.0,
"smoothing_factor": 0.0,
"dynatemp_range": 0.0,
"dynatemp_exponent": 1.0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"customizer": false,
"vpn": false,
"service": false,
"education": false,
"special": false,
"filtered": false,
"reset_suspicion": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"kudos_details": {
"accumulated": 0,
"gifted": 0,
"donated": 0,
"admin": 0,
"received": 0,
"recurring": 0,
Expand All @@ -29,6 +30,7 @@
"flagged": false,
"vpn": false,
"service": false,
"education": false,
"special": false,
"suspicious": 0,
"pseudonymous": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"id": "",
"kudos": 0.0,
"message": ""
"message": "",
"warnings": [
{
"code": "NoAvailableWorker",
"message": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"id": "",
"kudos": 0.0,
"message": ""
"message": "",
"warnings": [
{
"code": "NoAvailableWorker",
"message": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "",
"username": "",
"name": "",
"kudos": 0,
"expiry": "2021-01-01T00:00:00Z",
"utilized": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "",
"username": "",
"name": "",
"kudos": 0,
"expiry": "2021-01-01T00:00:00Z",
"utilized": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "",
"username": "",
"name": "",
"kudos": 0,
"expiry": "2021-01-01T00:00:00Z",
"utilized": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"kudos_details": {
"accumulated": 0,
"gifted": 0,
"donated": 0,
"admin": 0,
"received": 0,
"recurring": 0,
Expand All @@ -29,6 +30,7 @@
"flagged": false,
"vpn": false,
"service": false,
"education": false,
"special": false,
"suspicious": 0,
"pseudonymous": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"kudos_details": {
"accumulated": 0,
"gifted": 0,
"donated": 0,
"admin": 0,
"received": 0,
"recurring": 0,
Expand All @@ -29,6 +30,7 @@
"flagged": false,
"vpn": false,
"service": false,
"education": false,
"special": false,
"suspicious": 0,
"pseudonymous": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"customizer": false,
"vpn": false,
"service": false,
"education": false,
"special": false,
"new_suspicion": 0,
"contact": "[email protected]",
Expand Down

0 comments on commit f90cd73

Please sign in to comment.