Skip to content

Commit bd64abe

Browse files
committed
feat: bare-bones 'style' api update support
This just brings the testing up to the point of only failing on the unsupported/not yet added endpoints. See Haidra-Org/AI-Horde#465 for more information.
1 parent 2d3530f commit bd64abe

File tree

44 files changed

+791
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+791
-28
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# _styles
2+
::: horde_sdk.ai_horde_api.apimodels._styles

docs/response_field_names_and_descriptions.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,13 @@
444444
"int",
445445
"None"
446446
]
447+
},
448+
"styles": {
449+
"description": "The styles this user has created.",
450+
"types": [
451+
"list[horde_sdk.ai_horde_api.apimodels._styles.ResponseModelStylesUser]",
452+
"None"
453+
]
447454
}
448455
},
449456
"HordePerformanceResponse": {
@@ -726,6 +733,13 @@
726733
"list[str]",
727734
"None"
728735
]
736+
},
737+
"ttl": {
738+
"description": "The amount of seconds before this job is considered stale and aborted.",
739+
"types": [
740+
"int",
741+
"None"
742+
]
729743
}
730744
},
731745
"JobSubmitResponse": {
@@ -1308,6 +1322,13 @@
13081322
"str",
13091323
"None"
13101324
]
1325+
},
1326+
"ttl": {
1327+
"description": "The amount of seconds before this job is considered stale and aborted.",
1328+
"types": [
1329+
"int",
1330+
"None"
1331+
]
13111332
}
13121333
},
13131334
"TextStatsModelResponse": {

horde_sdk/ai_horde_api/apimodels/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
NewsRequest,
4545
NewsResponse,
4646
)
47+
from horde_sdk.ai_horde_api.apimodels._styles import ResponseModelStylesUser
4748
from horde_sdk.ai_horde_api.apimodels._users import (
4849
ActiveGenerations,
4950
ContributionsDetails,
@@ -210,6 +211,7 @@
210211
"Newspiece",
211212
"NewsRequest",
212213
"NewsResponse",
214+
"ResponseModelStylesUser",
213215
"ListUsersDetailsRequest",
214216
"ListUsersDetailsResponse",
215217
"ModifyUser",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from enum import auto
2+
3+
from pydantic import Field
4+
from strenum import StrEnum
5+
6+
from horde_sdk.generic_api.apimodels import HordeAPIDataObject
7+
8+
9+
class StyleType(StrEnum):
10+
"""An enum representing the different types of styles."""
11+
12+
image = auto()
13+
text = auto()
14+
15+
16+
class ResponseModelStylesUser(HordeAPIDataObject):
17+
name: str
18+
id_: str = Field(alias="id")
19+
type_: StyleType = Field(alias="type")

horde_sdk/ai_horde_api/apimodels/_users.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pydantic import Field, RootModel
44
from typing_extensions import override
55

6+
from horde_sdk.ai_horde_api.apimodels._styles import ResponseModelStylesUser
67
from horde_sdk.ai_horde_api.apimodels.base import BaseAIHordeRequest
78
from horde_sdk.ai_horde_api.endpoints import AI_HORDE_API_ENDPOINT_SUBPATH
89
from horde_sdk.ai_horde_api.fields import UUID_Identifier
@@ -52,6 +53,9 @@ class UserKudosDetails(HordeAPIDataObject):
5253
recurring: float | None = Field(0)
5354
"""The amount of Kudos this user has received from recurring rewards."""
5455

56+
styled: float | None = Field(0)
57+
"""The amount of Kudos this user has received from styling images."""
58+
5559

5660
class MonthlyKudos(HordeAPIDataObject):
5761
amount: int | None = Field(default=None)
@@ -85,6 +89,7 @@ class UserRecords(HordeAPIDataObject):
8589
fulfillment: UserAmountRecords | None = None
8690
request: UserAmountRecords | None = None
8791
usage: UserThingRecords | None = None
92+
style: UserAmountRecords | None = None
8893

8994

9095
class UsageDetails(HordeAPIDataObject):
@@ -264,6 +269,9 @@ def get_api_model_name(cls) -> str | None:
264269
"""Whether this user has been invited to join a worker to the horde and how many of them.
265270
When 0, this user cannot add (new) workers to the horde."""
266271

272+
styles: list[ResponseModelStylesUser] | None = None
273+
"""The styles this user has created."""
274+
267275

268276
@Unhashable
269277
@Unequatable

horde_sdk/ai_horde_api/apimodels/generate/_pop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ class ImageGenerateJobPopResponse(
232232
"""(Obsolete) The r2 upload link to use to upload this image."""
233233
r2_uploads: list[str] | None = None
234234
"""The r2 upload links for each this image. Each index matches the ID in self.ids"""
235+
ttl: int | None = None
236+
"""The amount of seconds before this job is considered stale and aborted."""
235237

236238
@field_validator("source_processing")
237239
def source_processing_must_be_known(cls, v: str | KNOWN_SOURCE_PROCESSING) -> str | KNOWN_SOURCE_PROCESSING:

horde_sdk/ai_horde_api/apimodels/generate/text/_pop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class TextGenerateJobPopResponse(
6060
"""The soft prompt requested for this generation."""
6161
model: str | None = Field(default=None)
6262
"""The model requested for this generation."""
63+
ttl: int | None = None
64+
"""The amount of seconds before this job is considered stale and aborted."""
6365

6466
@field_validator("id_", mode="before")
6567
def validate_id(cls, v: str | JobID) -> JobID | str:

horde_sdk/generic_api/utils/swagger.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,12 @@ def get_endpoint_method_examples(
449449
# Iterate through each defined response for the HTTP method.
450450
for http_status_code_str, response_definition in endpoint_method_definition.responses.items():
451451
# Convert the HTTP status code string to an HTTPStatusCode object.
452-
http_status_code_object = HTTPStatusCode(int(http_status_code_str))
452+
try:
453+
http_status_code_object = HTTPStatusCode(int(http_status_code_str))
454+
except ValueError as e:
455+
logger.error(f"Failed to convert {http_status_code_str} to an HTTPStatusCode object: {e}")
456+
logger.error(f"response_definition: {response_definition}")
457+
raise
453458

454459
# Get the response example for this HTTP status code.
455460
example_response = self.get_response_example(response_definition)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "My Awesome Collection",
3+
"info": "Collection of optimistic styles",
4+
"public": true,
5+
"styles": [
6+
"a"
7+
]
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "My Awesome Collection",
3+
"info": "Collection of optimistic styles",
4+
"public": true,
5+
"styles": [
6+
"a"
7+
]
8+
}

0 commit comments

Comments
 (0)