From f90cd732307e47004c1906b670c4a1be44aef366 Mon Sep 17 00:00:00 2001 From: db0 Date: Tue, 19 Mar 2024 00:15:30 +0100 Subject: [PATCH] feat: support remix feat: Support for extra_source_images fix: Run scripts to update API ref feat: added missing keys fix: make `ImageGenerateAsyncResponse` hashable --- codegen/ai_horde_codegen_10072023.py | 3 +++ .../request_field_names_and_descriptions.json | 4 ++++ ...response_field_names_and_descriptions.json | 12 ++++++++++ horde_sdk/ai_horde_api/apimodels/__init__.py | 8 ++++++- .../ai_horde_api/apimodels/_find_user.py | 10 ++++++++ horde_sdk/ai_horde_api/apimodels/base.py | 24 +++++++++++++++++++ .../ai_horde_api/apimodels/generate/_async.py | 11 +++++++++ .../ai_horde_api/apimodels/generate/_pop.py | 3 +++ horde_sdk/ai_horde_api/consts.py | 1 + .../_v2_generate_async_post.json | 2 +- .../_v2_generate_text_async_post.json | 1 + .../_v2_users_user_id_put.json | 1 + .../_v2_find_user_get_200.json | 2 ++ .../_v2_generate_async_post_202.json | 8 ++++++- .../_v2_generate_text_async_post_202.json | 8 ++++++- .../_v2_sharedkeys_put_200.json | 1 + .../_v2_sharedkeys_sharedkey_id_get_200.json | 1 + ..._v2_sharedkeys_sharedkey_id_patch_200.json | 1 + .../example_responses/_v2_users_get_200.json | 2 ++ .../_v2_users_user_id_get_200.json | 2 ++ .../_v2_users_user_id_put_200.json | 1 + 21 files changed, 102 insertions(+), 4 deletions(-) diff --git a/codegen/ai_horde_codegen_10072023.py b/codegen/ai_horde_codegen_10072023.py index fef20fb..68038b0 100644 --- a/codegen/ai_horde_codegen_10072023.py +++ b/codegen/ai_horde_codegen_10072023.py @@ -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.", diff --git a/docs/request_field_names_and_descriptions.json b/docs/request_field_names_and_descriptions.json index 8a0a3f1..283746e 100644 --- a/docs/request_field_names_and_descriptions.json +++ b/docs/request_field_names_and_descriptions.json @@ -205,6 +205,10 @@ [ "source_mask", null + ], + [ + "extra_source_images", + null ] ], "ImageGenerateCheckRequest": [ diff --git a/docs/response_field_names_and_descriptions.json b/docs/response_field_names_and_descriptions.json index 9f7eca2..6503534 100644 --- a/docs/response_field_names_and_descriptions.json +++ b/docs/response_field_names_and_descriptions.json @@ -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)." @@ -261,6 +265,10 @@ [ "kudos", null + ], + [ + "warnings", + null ] ], "ImageGenerateCheckResponse": [ @@ -338,6 +346,10 @@ "source_mask", null ], + [ + "extra_source_images", + null + ], [ "r2_upload", null diff --git a/horde_sdk/ai_horde_api/apimodels/__init__.py b/horde_sdk/ai_horde_api/apimodels/__init__.py index b899b9f..bd637f6 100644 --- a/horde_sdk/ai_horde_api/apimodels/__init__.py +++ b/horde_sdk/ai_horde_api/apimodels/__init__.py @@ -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, @@ -112,6 +117,7 @@ "StatsModelsResponse", "StatsModelsTimeframe", "TIPayloadEntry", + "ExtraSourceImageEntry", "GenMetadataEntry", "UsageDetails", "UserAmountRecords", diff --git a/horde_sdk/ai_horde_api/apimodels/_find_user.py b/horde_sdk/ai_horde_api/apimodels/_find_user.py index 44bff46..91689d3 100644 --- a/horde_sdk/ai_horde_api/apimodels/_find_user.py +++ b/horde_sdk/ai_horde_api/apimodels/_find_user.py @@ -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.", @@ -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).", diff --git a/horde_sdk/ai_horde_api/apimodels/base.py b/horde_sdk/ai_horde_api/apimodels/base.py index 331eb52..e7a857f 100644 --- a/horde_sdk/ai_horde_api/apimodels/base.py +++ b/horde_sdk/ai_horde_api/apimodels/base.py @@ -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. diff --git a/horde_sdk/ai_horde_api/apimodels/generate/_async.py b/horde_sdk/ai_horde_api/apimodels/generate/_async.py index 1d9ccc3..559764b 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/_async.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/_async.py @@ -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 @@ -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]]: @@ -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 @@ -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: diff --git a/horde_sdk/ai_horde_api/apimodels/generate/_pop.py b/horde_sdk/ai_horde_api/apimodels/generate/_pop.py index af2d8f0..34a22e0 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/_pop.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/_pop.py @@ -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 @@ -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 diff --git a/horde_sdk/ai_horde_api/consts.py b/horde_sdk/ai_horde_api/consts.py index 167a999..3fe6148 100644 --- a/horde_sdk/ai_horde_api/consts.py +++ b/horde_sdk/ai_horde_api/consts.py @@ -207,6 +207,7 @@ class METADATA_TYPE(StrEnum): censorship = auto() source_image = auto() source_mask = auto() + extra_source_images = auto() batch_index = auto() diff --git a/tests/test_data/ai_horde_api/example_payloads/_v2_generate_async_post.json b/tests/test_data/ai_horde_api/example_payloads/_v2_generate_async_post.json index 95fb259..b58a283 100644 --- a/tests/test_data/ai_horde_api/example_payloads/_v2_generate_async_post.json +++ b/tests/test_data/ai_horde_api/example_payloads/_v2_generate_async_post.json @@ -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", diff --git a/tests/test_data/ai_horde_api/example_payloads/_v2_generate_text_async_post.json b/tests/test_data/ai_horde_api/example_payloads/_v2_generate_text_async_post.json index dc0fe3b..60469b2 100644 --- a/tests/test_data/ai_horde_api/example_payloads/_v2_generate_text_async_post.json +++ b/tests/test_data/ai_horde_api/example_payloads/_v2_generate_text_async_post.json @@ -26,6 +26,7 @@ "" ], "min_p": 0.0, + "smoothing_factor": 0.0, "dynatemp_range": 0.0, "dynatemp_exponent": 1.0 }, diff --git a/tests/test_data/ai_horde_api/example_payloads/_v2_users_user_id_put.json b/tests/test_data/ai_horde_api/example_payloads/_v2_users_user_id_put.json index 1e4ddc1..e1b7866 100644 --- a/tests/test_data/ai_horde_api/example_payloads/_v2_users_user_id_put.json +++ b/tests/test_data/ai_horde_api/example_payloads/_v2_users_user_id_put.json @@ -12,6 +12,7 @@ "customizer": false, "vpn": false, "service": false, + "education": false, "special": false, "filtered": false, "reset_suspicion": false, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_find_user_get_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_find_user_get_200.json index a49f466..23776a6 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_find_user_get_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_find_user_get_200.json @@ -9,6 +9,7 @@ "kudos_details": { "accumulated": 0, "gifted": 0, + "donated": 0, "admin": 0, "received": 0, "recurring": 0, @@ -29,6 +30,7 @@ "flagged": false, "vpn": false, "service": false, + "education": false, "special": false, "suspicious": 0, "pseudonymous": false, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_generate_async_post_202.json b/tests/test_data/ai_horde_api/example_responses/_v2_generate_async_post_202.json index fb1605a..0d53883 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_generate_async_post_202.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_generate_async_post_202.json @@ -1,5 +1,11 @@ { "id": "", "kudos": 0.0, - "message": "" + "message": "", + "warnings": [ + { + "code": "NoAvailableWorker", + "message": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] } diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_generate_text_async_post_202.json b/tests/test_data/ai_horde_api/example_responses/_v2_generate_text_async_post_202.json index fb1605a..0d53883 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_generate_text_async_post_202.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_generate_text_async_post_202.json @@ -1,5 +1,11 @@ { "id": "", "kudos": 0.0, - "message": "" + "message": "", + "warnings": [ + { + "code": "NoAvailableWorker", + "message": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + ] } diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_put_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_put_200.json index 3b4a461..4f99993 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_put_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_put_200.json @@ -1,6 +1,7 @@ { "id": "", "username": "", + "name": "", "kudos": 0, "expiry": "2021-01-01T00:00:00Z", "utilized": 0, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_get_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_get_200.json index 3b4a461..4f99993 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_get_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_get_200.json @@ -1,6 +1,7 @@ { "id": "", "username": "", + "name": "", "kudos": 0, "expiry": "2021-01-01T00:00:00Z", "utilized": 0, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_patch_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_patch_200.json index 3b4a461..4f99993 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_patch_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_sharedkeys_sharedkey_id_patch_200.json @@ -1,6 +1,7 @@ { "id": "", "username": "", + "name": "", "kudos": 0, "expiry": "2021-01-01T00:00:00Z", "utilized": 0, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_users_get_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_users_get_200.json index a49f466..23776a6 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_users_get_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_users_get_200.json @@ -9,6 +9,7 @@ "kudos_details": { "accumulated": 0, "gifted": 0, + "donated": 0, "admin": 0, "received": 0, "recurring": 0, @@ -29,6 +30,7 @@ "flagged": false, "vpn": false, "service": false, + "education": false, "special": false, "suspicious": 0, "pseudonymous": false, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_get_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_get_200.json index a49f466..23776a6 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_get_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_get_200.json @@ -9,6 +9,7 @@ "kudos_details": { "accumulated": 0, "gifted": 0, + "donated": 0, "admin": 0, "received": 0, "recurring": 0, @@ -29,6 +30,7 @@ "flagged": false, "vpn": false, "service": false, + "education": false, "special": false, "suspicious": 0, "pseudonymous": false, diff --git a/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_put_200.json b/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_put_200.json index 2a3b3d4..2560d2c 100644 --- a/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_put_200.json +++ b/tests/test_data/ai_horde_api/example_responses/_v2_users_user_id_put_200.json @@ -12,6 +12,7 @@ "customizer": false, "vpn": false, "service": false, + "education": false, "special": false, "new_suspicion": 0, "contact": "email@example.com",