From cc75d63e78958b16d9a18f378b7db7dd717a71a8 Mon Sep 17 00:00:00 2001 From: tazlin Date: Sat, 21 Sep 2024 17:15:22 -0400 Subject: [PATCH] fix: explicitly specify `default` arg for pydantic `Field`s Either the behavior changed at some point or I overlooked the fact that the `default` arg is not propagated through to mypy properly if it is specified positionally. This makes it explicit in all cases to fix the bug, if there is one, and at the very least least clarifies the meaning of the argument. --- horde_sdk/ai_horde_api/apimodels/_stats.py | 10 ++-- horde_sdk/ai_horde_api/apimodels/_status.py | 52 +++++++++---------- horde_sdk/ai_horde_api/apimodels/_users.py | 42 +++++++-------- .../ai_horde_api/apimodels/alchemy/_pop.py | 10 ++-- .../ai_horde_api/apimodels/generate/_pop.py | 24 ++++----- .../apimodels/generate/text/_async.py | 40 +++++++------- .../apimodels/generate/text/_pop.py | 14 ++--- .../apimodels/generate/text/_status.py | 4 +- .../apimodels/workers/_workers.py | 38 +++++++------- horde_sdk/generic_api/utils/swagger.py | 36 ++++++------- 10 files changed, 135 insertions(+), 135 deletions(-) diff --git a/horde_sdk/ai_horde_api/apimodels/_stats.py b/horde_sdk/ai_horde_api/apimodels/_stats.py index 7b35e4e..83a0f69 100644 --- a/horde_sdk/ai_horde_api/apimodels/_stats.py +++ b/horde_sdk/ai_horde_api/apimodels/_stats.py @@ -97,7 +97,7 @@ class ImageStatsModelsRequest(BaseAIHordeRequest): ) model_state: MODEL_STATE = Field( - MODEL_STATE.all, + default=MODEL_STATE.all, ) """The state of the models to get stats for. Known models are models that are known to the system.""" @@ -124,11 +124,11 @@ def get_default_success_response_type(cls) -> type[ImageStatsModelsResponse]: class SinglePeriodImgStat(HordeAPIDataObject): images: int | None = Field( - None, + default=None, ) """The amount of images generated during this period.""" ps: int | None = Field( - None, + default=None, ) """The amount of pixelsteps generated during this period.""" @@ -255,11 +255,11 @@ def get_default_success_response_type(cls) -> type[TextStatsModelResponse]: class SinglePeriodTxtStat(HordeAPIDataObject): requests: int | None = Field( - None, + default=None, ) """The number of requests made during this period.""" tokens: int | None = Field( - None, + default=None, ) """The number of tokens generated during this period.""" diff --git a/horde_sdk/ai_horde_api/apimodels/_status.py b/horde_sdk/ai_horde_api/apimodels/_status.py index 1159401..51f983b 100644 --- a/horde_sdk/ai_horde_api/apimodels/_status.py +++ b/horde_sdk/ai_horde_api/apimodels/_status.py @@ -50,14 +50,14 @@ def get_default_success_response_type(cls) -> type[AIHordeHeartbeatResponse]: class HordePerformanceResponse(HordeResponseBaseModel): interrogator_count: int | None = Field( - None, + default=None, description=( "How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes." ), ) """How many workers are actively processing image interrogations in this {horde_noun} in the past 5 minutes.""" interrogator_thread_count: int | None = Field( - None, + default=None, description=( "How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5" " minutes." @@ -66,35 +66,35 @@ class HordePerformanceResponse(HordeResponseBaseModel): """How many worker threads are actively processing image interrogation in this {horde_noun} in the past 5 minutes.""" past_minute_megapixelsteps: float | None = Field( - None, + default=None, ) """How many megapixelsteps this horde generated in the last minute.""" past_minute_tokens: float | None = Field( - None, + default=None, ) """How many tokens this horde generated in the last minute.""" queued_forms: float | None = Field( - None, + default=None, ) """The amount of image interrogations waiting and processing currently in this horde.""" queued_megapixelsteps: float | None = Field( - None, + default=None, ) """The amount of megapixelsteps in waiting and processing requests currently in this horde.""" queued_requests: int | None = Field( - None, + default=None, ) """The amount of waiting and processing image requests currently in this horde.""" queued_text_requests: int | None = Field( - None, + default=None, ) """The amount of waiting and processing text requests currently in this horde.""" queued_tokens: float | None = Field( - None, + default=None, ) """The amount of tokens in waiting and processing requests currently in this horde.""" text_thread_count: int | None = Field( - None, + default=None, description=( "How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5" " minutes." @@ -103,11 +103,11 @@ class HordePerformanceResponse(HordeResponseBaseModel): """How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.""" text_worker_count: int | None = Field( - None, + default=None, ) """How many workers are actively processing prompt generations in this horde in the past 5 minutes.""" thread_count: int | None = Field( - None, + default=None, description=( "How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5" " minutes." @@ -116,7 +116,7 @@ class HordePerformanceResponse(HordeResponseBaseModel): """How many worker threads are actively processing prompt generations in this {horde_noun} in the past 5 minutes.""" worker_count: int | None = Field( - None, + default=None, ) """How many workers are actively processing prompt generations in this horde in the past 5 minutes.""" @@ -150,13 +150,13 @@ def get_default_success_response_type(cls) -> type[HordePerformanceResponse]: class Newspiece(HordeAPIObject): date_published: str | None = Field( - None, + default=None, ) """The date this newspiece was published.""" - importance: str | None = Field(None, examples=["Information"]) + importance: str | None = Field(default=None, examples=["Information"]) """How critical this piece of news is.""" newspiece: str | None = Field( - None, + default=None, ) """The actual piece of news.""" @@ -212,11 +212,11 @@ def get_default_success_response_type(cls) -> type[NewsResponse]: class ActiveModelLite(HordeAPIObject): count: int | None = Field( - None, + default=None, ) """How many of workers in this horde are running this model.""" name: str | None = Field( - None, + default=None, ) """The Name of a model available by workers in this horde.""" @@ -228,19 +228,19 @@ def get_api_model_name(cls) -> str | None: class ActiveModel(ActiveModelLite): eta: int | None = Field( - None, + default=None, ) """Estimated time in seconds for this model's queue to be cleared.""" jobs: float | None = Field( - None, + default=None, ) """The job count waiting to be generated by this model.""" performance: float | None = Field( - None, + default=None, ) """The average speed of generation for this model.""" queued: float | None = Field( - None, + default=None, ) """The amount waiting to be generated by this model.""" type_: MODEL_TYPE | None = Field( @@ -283,7 +283,7 @@ class HordeStatusModelsAllRequest(BaseAIHordeRequest): ) type_: MODEL_TYPE = Field( - MODEL_TYPE.image, + default=MODEL_TYPE.image, examples=[MODEL_TYPE.image, MODEL_TYPE.text], alias="type", ) @@ -379,17 +379,17 @@ def get_default_success_response_type(cls) -> type[HordeStatusModelsSingleRespon class HordeModes(HordeAPIObject): maintenance_mode: bool = Field( - False, + default=False, ) """Whether the horde is in maintenance mode.""" invite_only_mode: bool = Field( - False, + default=False, ) """Whether the horde is in invite-only mode.""" raid_mode: bool = Field( - False, + default=False, ) """Whether the horde is in raid mode.""" diff --git a/horde_sdk/ai_horde_api/apimodels/_users.py b/horde_sdk/ai_horde_api/apimodels/_users.py index f730db3..3e3cd6b 100644 --- a/horde_sdk/ai_horde_api/apimodels/_users.py +++ b/horde_sdk/ai_horde_api/apimodels/_users.py @@ -335,21 +335,21 @@ def get_default_success_response_type(cls) -> type[UserDetailsResponse]: class _ModifyUserBase(HordeAPIDataObject): admin_comment: str | None = Field( - None, + default=None, max_length=500, min_length=5, ) """Add further information about this user for the other admins.""" concurrency: int | None = Field( - None, + default=None, ge=0, le=500, ) """The amount of concurrent request this user can have.""" contact: str | None = Field( - None, + default=None, examples=["email@example.com"], max_length=500, min_length=5, @@ -358,94 +358,94 @@ class _ModifyUserBase(HordeAPIDataObject): moderators.""" customizer: bool | None = Field( - None, + default=None, ) """When set to true, the user will be able to serve custom Stable Diffusion models which do not exist in the Official AI Horde Model Reference.""" education: bool | None = Field( - None, + default=None, ) """When set to true, the user is considered an education account and some options become more restrictive.""" filtered: bool | None = Field( - None, + default=None, ) """When set to true, the replacement filter will always be applied against this user""" flagged: bool | None = Field( - None, + default=None, ) """When set to true, the user cannot transfer kudos and all their workers are put into permanent maintenance.""" moderator: bool | None = Field( - None, + default=None, ) """Set to true to make this user a horde moderator.""" monthly_kudos: int | None = Field( - None, + default=None, ) """When specified, will start assigning the user monthly kudos, starting now!""" public_workers: bool | None = Field( - None, + default=None, ) """Set to true to make this user display their worker IDs.""" service: bool | None = Field( - None, + default=None, ) """When set to true, the user is considered a service account proxying the requests for other users.""" special: bool | None = Field( - None, + default=None, ) """When set to true, The user can send special payloads.""" trusted: bool | None = Field( - None, + default=None, ) """When set to true,the user and their servers will not be affected by suspicion.""" usage_multiplier: float | None = Field( - None, + default=None, ge=0.1, le=10.0, ) """The amount by which to multiply the users kudos consumption.""" username: str | None = Field( - None, + default=None, max_length=100, min_length=3, ) """When specified, will change the username. No profanity allowed!""" vpn: bool | None = Field( - None, + default=None, ) """When set to true, the user will be able to onboard workers behind a VPN. This should be used as a temporary solution until the user is trusted.""" worker_invited: int | None = Field( - None, + default=None, ) """Set to the amount of workers this user is allowed to join to the horde when in worker invite-only mode.""" class ModifyUser(_ModifyUserBase): - kudos: float | None = Field(None) + kudos: float | None = Field(default=None) """The amount of kudos to modify (can be negative).""" - reset_suspicion: bool | None = Field(None) + reset_suspicion: bool | None = Field(default=None) """Set the user's suspicion back to 0.""" class ModifyUserReply(_ModifyUserBase): - new_kudos: float | None = Field(None) + new_kudos: float | None = Field(default=None) """The new amount of kudos this user has.""" - new_suspicion: int | None = Field(None) + new_suspicion: int | None = Field(default=None) """The new amount of suspicion this user has.""" diff --git a/horde_sdk/ai_horde_api/apimodels/alchemy/_pop.py b/horde_sdk/ai_horde_api/apimodels/alchemy/_pop.py index 3f540b2..76f6f0a 100644 --- a/horde_sdk/ai_horde_api/apimodels/alchemy/_pop.py +++ b/horde_sdk/ai_horde_api/apimodels/alchemy/_pop.py @@ -70,11 +70,11 @@ def validate_form(cls, v: str | KNOWN_ALCHEMY_TYPES) -> KNOWN_ALCHEMY_TYPES | st payload: AlchemyFormPayloadStable | None = None """The setting for this interrogation form.""" r2_upload: str | None = Field( - None, + default=None, ) """The URL in which the post-processed image can be uploaded.""" source_image: str | None = Field( - None, + default=None, ) """The URL From which the source image can be downloaded.""" @@ -88,7 +88,7 @@ def get_api_model_name(cls) -> str | None: return "NoValidInterrogationsFoundStable" bridge_version: int | None = Field( - None, + default=None, description=( "How many waiting requests were skipped because they require a higher version of the bridge than this" " worker is running (upgrade if you see this in your skipped list)." @@ -99,7 +99,7 @@ def get_api_model_name(cls) -> str | None: """How many waiting requests were skipped because they require a higher version of the bridge than this worker is running (upgrade if you see this in your skipped list).""" untrusted: int | None = Field( - None, + default=None, description=( "How many waiting requests were skipped because they demanded a trusted worker which this worker is not." ), @@ -107,7 +107,7 @@ def get_api_model_name(cls) -> str | None: ) """How many waiting requests were skipped because they demanded a trusted worker which this worker is not.""" worker_id: int | None = Field( - None, + default=None, ge=0, ) """How many waiting requests were skipped because they demanded a specific worker.""" diff --git a/horde_sdk/ai_horde_api/apimodels/generate/_pop.py b/horde_sdk/ai_horde_api/apimodels/generate/_pop.py index ee3cebf..f7de943 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/_pop.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/_pop.py @@ -34,29 +34,29 @@ class NoValidRequestFound(HordeAPIObject): - blacklist: int | None = Field(None, ge=0) + blacklist: int | None = Field(default=None, ge=0) """How many waiting requests were skipped because they demanded a generation with a word that this worker does not accept.""" - bridge_version: int | None = Field(None, examples=[0], ge=0) + bridge_version: int | None = Field(default=None, examples=[0], ge=0) """How many waiting requests were skipped because they require a higher version of the bridge than this worker is running (upgrade if you see this in your skipped list).""" - kudos: int | None = Field(None) + kudos: int | None = Field(default=None) """How many waiting requests were skipped because the user didn't have enough kudos when this worker requires""" - models: int | None = Field(None, examples=[0], ge=0) + models: int | None = Field(default=None, examples=[0], ge=0) """How many waiting requests were skipped because they demanded a different model than what this worker provides.""" - nsfw: int | None = Field(None, ge=0) + nsfw: int | None = Field(default=None, ge=0) """How many waiting requests were skipped because they demanded a nsfw generation which this worker does not provide.""" performance: int | None = Field( - None, + default=None, ge=0, ) """How many waiting requests were skipped because they demanded a higher performance than this worker provides.""" - untrusted: int | None = Field(None, ge=0) + untrusted: int | None = Field(default=None, ge=0) """How many waiting requests were skipped because they demanded a trusted worker which this worker is not.""" worker_id: int | None = Field( - None, + default=None, ge=0, ) """How many waiting requests were skipped because they demanded a specific worker.""" @@ -205,7 +205,7 @@ class ImageGenerateJobPopResponse( v2 API Model: `GenerationPayloadStable` """ - id_: JobID | None = Field(None, alias="id") + id_: JobID | None = Field(default=None, alias="id") """(Obsolete) The UUID for this image generation.""" ids: list[JobID] """A list of UUIDs for image generation.""" @@ -432,13 +432,13 @@ class PopInput(HordeAPIObject): name: str """The Name of the Worker.""" nsfw: bool | None = Field( - False, + default=False, ) """Whether this worker can generate NSFW requests or not.""" priority_usernames: list[str] | None = None """The usernames that should be prioritized by this worker.""" require_upfront_kudos: bool | None = Field( - False, + default=False, description=( "If True, this worker will only pick up requests where the owner has the required kudos to consume already" " available." @@ -450,7 +450,7 @@ class PopInput(HordeAPIObject): """If True, this worker will only pick up requests where the owner has the required kudos to consume already available.""" threads: int | None = Field( - 1, + default=1, description=( "How many threads this worker is running. This is used to accurately the current power available in the" " horde." diff --git a/horde_sdk/ai_horde_api/apimodels/generate/text/_async.py b/horde_sdk/ai_horde_api/apimodels/generate/text/_async.py index f8d34ff..354dd6a 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/text/_async.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/text/_async.py @@ -32,7 +32,7 @@ class TextGenerateAsyncResponse( ContainsMessageResponseMixin, ): kudos: float | None = Field( - None, + default=None, ) """The expected kudos consumption for this request.""" warnings: list[SingleWarningEntry] | None = None @@ -89,7 +89,7 @@ class ModelPayloadRootKobold(HordeAPIDataObject): dynatemp_range: float | None = Field(0, ge=0.0, le=5.0) """Dynamic temperature range value.""" frmtadsnsp: bool | None = Field( - None, + default=None, description=( "Input formatting option. When enabled, adds a leading space to your input if there is no trailing" " whitespace at the end of the previous action." @@ -101,7 +101,7 @@ class ModelPayloadRootKobold(HordeAPIDataObject): """Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.""" frmtrmblln: bool | None = Field( - None, + default=None, description=( "Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in" " the output with one newline." @@ -113,14 +113,14 @@ class ModelPayloadRootKobold(HordeAPIDataObject): """Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in the output with one newline.""" frmtrmspch: bool | None = Field( - None, + default=None, examples=[ False, ], ) """Output formatting option. When enabled, removes #/@%}{+=~|\\^<> from the output.""" frmttriminc: bool | None = Field( - None, + default=None, description=( "Output formatting option. When enabled, removes some characters from the end of the output such that the" " output doesn't end in the middle of a sentence. If the output is less than one sentence long, does" @@ -133,7 +133,7 @@ class ModelPayloadRootKobold(HordeAPIDataObject): """Output formatting option. When enabled, removes some characters from the end of the output such that the output doesn't end in the middle of a sentence. If the output is less than one sentence long, does nothing.""" max_context_length: int | None = Field( - 1024, + default=1024, ge=80, le=32000, ) @@ -142,18 +142,18 @@ class ModelPayloadRootKobold(HordeAPIDataObject): """Number of tokens to generate.""" min_p: float | None = Field(0, ge=0.0, le=1.0) """Min-p sampling value.""" - n: int | None = Field(None, examples=[1], ge=1, le=20) + n: int | None = Field(default=None, examples=[1], ge=1, le=20) """The number of generations to produce.""" - rep_pen: float | None = Field(None, ge=1.0, le=3.0) + rep_pen: float | None = Field(default=None, ge=1.0, le=3.0) """Base repetition penalty value.""" - rep_pen_range: int | None = Field(None, ge=0, le=4096) + rep_pen_range: int | None = Field(default=None, ge=0, le=4096) """Repetition penalty range.""" - rep_pen_slope: float | None = Field(None, ge=0.0, le=10.0) + rep_pen_slope: float | None = Field(default=None, ge=0.0, le=10.0) """Repetition penalty slope.""" sampler_order: list[int] | None = None """The sampler order to use for the generation.""" singleline: bool | None = Field( - None, + default=None, description=( "Output formatting option. When enabled, removes everything after the first line of the output, including" " the newline." @@ -168,17 +168,17 @@ class ModelPayloadRootKobold(HordeAPIDataObject): """Quadratic sampling value.""" stop_sequence: list[str] | None = None """The stop sequences to use for the generation.""" - temperature: float | None = Field(None, ge=0.0, le=5.0) + temperature: float | None = Field(default=None, ge=0.0, le=5.0) """Temperature value.""" - tfs: float | None = Field(None, ge=0.0, le=1.0) + tfs: float | None = Field(default=None, ge=0.0, le=1.0) """Tail free sampling value.""" - top_a: float | None = Field(None, ge=0.0, le=1.0) + top_a: float | None = Field(default=None, ge=0.0, le=1.0) """Top-a sampling value.""" - top_k: int | None = Field(None, ge=0, le=100) + top_k: int | None = Field(default=None, ge=0, le=100) """Top-k sampling value.""" - top_p: float | None = Field(None, ge=0.001, le=1.0) + top_p: float | None = Field(default=None, ge=0.001, le=1.0) """Top-p sampling value.""" - typical: float | None = Field(None, ge=0.0, le=1.0) + typical: float | None = Field(default=None, ge=0.0, le=1.0) """Typical sampling value.""" use_default_badwordsids: bool | None = None """When True, uses the default KoboldAI bad word IDs.""" @@ -224,15 +224,15 @@ class TextGenerateAsyncRequest( Feature is restricted to Trusted users and Patreons.""" extra_source_images: list[ExtraSourceImageEntry] | None = None """Any extra source images that should be used for this request; e.g., for multi-modal models.""" - proxied_account: str | None = Field(None) + proxied_account: str | None = Field(default=None) """If using a service account as a proxy, provide this value to identify the actual account from which this request is coming from.""" softprompt: str | None = Field( - None, + default=None, min_length=1, ) """Specify which softprompt needs to be used to service this request.""" - webhook: str | None = Field(None) + webhook: str | None = Field(default=None) """Provide a URL where the AI Horde will send a POST call after each delivered generation. The request will include the details of the job as well as the request ID.""" diff --git a/horde_sdk/ai_horde_api/apimodels/generate/text/_pop.py b/horde_sdk/ai_horde_api/apimodels/generate/text/_pop.py index 663e4cc..164ee57 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/text/_pop.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/text/_pop.py @@ -27,13 +27,13 @@ class ModelPayloadKobold(ModelPayloadRootKobold): class NoValidRequestFoundKobold(NoValidRequestFound): - max_context_length: int | None = Field(None) + max_context_length: int | None = Field(default=None) """How many waiting requests were skipped because they demanded a higher max_context_length than what this worker provides.""" - max_length: int | None = Field(None) + max_length: int | None = Field(default=None) """How many waiting requests were skipped because they demanded a higher max_length than what this worker provides.""" - matching_softprompt: int | None = Field(None) + matching_softprompt: int | None = Field(default=None) """How many waiting requests were skipped because they demanded an available soft-prompt which this worker does not have.""" @@ -50,15 +50,15 @@ class TextGenerateJobPopResponse( ): payload: ModelPayloadKobold """The settings for this text generation.""" - id_: JobID | None = Field(None, alias="id") + id_: JobID | None = Field(default=None, alias="id") """The UUID for this text generation.""" ids: list[JobID] """The UUIDs for this text generations.""" skipped: NoValidRequestFoundKobold = Field(NoValidRequestFoundKobold()) """The skipped requests that were not valid for this worker.""" - softprompt: str | None = Field(None) + softprompt: str | None = Field(default=None) """The soft prompt requested for this generation.""" - model: str | None = Field(None) + model: str | None = Field(default=None) """The model requested for this generation.""" @field_validator("id_", mode="before") @@ -138,7 +138,7 @@ class _PopInputKobold(PopInput): """The maximum amount of tokens this worker can generate.""" max_context_length: int = Field(2048) """The max amount of context to submit to this AI for sampling.""" - softprompts: list[str] | None = Field(None) + softprompts: list[str] | None = Field(default=None) """The available softprompt files on this worker for the currently running model.""" diff --git a/horde_sdk/ai_horde_api/apimodels/generate/text/_status.py b/horde_sdk/ai_horde_api/apimodels/generate/text/_status.py index 061760a..eaf3094 100644 --- a/horde_sdk/ai_horde_api/apimodels/generate/text/_status.py +++ b/horde_sdk/ai_horde_api/apimodels/generate/text/_status.py @@ -14,13 +14,13 @@ class GenerationKobold(Generation): - id_: str | None = Field(None, title="Generation ID") + id_: str | None = Field(default=None, title="Generation ID") """The ID for this generation.""" gen_metadata: list[GenMetadataEntry] | None = None # FIXME: API declares a `GenerationMetadataKobold` here """Extra metadata about faulted or defaulted components of the generation.""" seed: int | None = Field(0, title="Generation Seed") """The seed which generated this text.""" - text: str | None = Field(None, min_length=0, title="Generated Text") + text: str | None = Field(default=None, min_length=0, title="Generated Text") """The generated text.""" @override diff --git a/horde_sdk/ai_horde_api/apimodels/workers/_workers.py b/horde_sdk/ai_horde_api/apimodels/workers/_workers.py index 1aceb35..98240c0 100644 --- a/horde_sdk/ai_horde_api/apimodels/workers/_workers.py +++ b/horde_sdk/ai_horde_api/apimodels/workers/_workers.py @@ -19,7 +19,7 @@ class TeamDetailsLite(HordeAPIObject): name: str | None = None """The Name given to this team.""" - id_: str | TeamID | None = Field(None, alias="id") + id_: str | TeamID | None = Field(default=None, alias="id") """The UUID of this team.""" @override @@ -89,11 +89,11 @@ class WorkerDetailItem(HordeAPIObject): """The forms this worker supports.""" team: TeamDetailsLite | None = None """The team this worker belongs to.""" - contact: str | None = Field(None, min_length=4, max_length=500) + contact: str | None = Field(default=None, min_length=4, max_length=500) """(Privileged) Contact details for the horde admins to reach the owner of this worker in emergencies.""" bridge_agent: str = Field(max_length=1000, examples=["AI Horde Worker reGen:4.1.0:"]) """The bridge agent name, version and website. Example: AI Horde Worker reGen:4.1.0:""" - max_pixels: int | None = Field(None, examples=[262144]) + max_pixels: int | None = Field(default=None, examples=[262144]) """The maximum pixels in resolution this worker can generate. Example: 262144""" megapixelsteps_generated: int | None = None """How many megapixelsteps this worker has generated until now.""" @@ -102,18 +102,18 @@ class WorkerDetailItem(HordeAPIObject): painting: bool | None = None """If True, this worker supports and allows inpainting requests.""" post_processing: bool | None = Field( - None, + default=None, validation_alias=AliasChoices("post_processing", "post-processing"), serialization_alias="post-processing", ) """If True, this worker supports and allows post-processing requests.""" lora: bool | None = None """If True, this worker supports and allows lora requests.""" - max_length: int | None = Field(None, examples=[80]) + max_length: int | None = Field(default=None, examples=[80]) """The maximum tokens this worker can generate.""" - max_context_length: int | None = Field(None, examples=[80]) + max_context_length: int | None = Field(default=None, examples=[80]) """The maximum tokens this worker can read.""" - tokens_generated: int | None = Field(None, examples=[0]) + tokens_generated: int | None = Field(default=None, examples=[0]) """How many tokens this worker has generated until now. """ @override @@ -196,7 +196,7 @@ class AllWorkersDetailsRequest(BaseAIHordeRequest, APIKeyAllowedInRequestMixin): type_: WORKER_TYPE = Field(WORKER_TYPE.all, alias="type") """Filter workers by type. Default is 'all' which returns all workers.""" - name: str | None = Field(None) + name: str | None = Field(default=None) """Returns a worker matching the exact name provided. Case insensitive.""" @override @@ -304,16 +304,16 @@ def is_api_key_required(cls) -> bool: class ModifyWorkerResponse(HordeResponse): - info: str | None = Field(None) + info: str | None = Field(default=None) """The new state of the 'info' var for this worker.""" - maintenance: bool | None = Field(None) + maintenance: bool | None = Field(default=None) """The new state of the 'maintenance' var for this worker. When True, this worker will not pick up any new requests.""" - name: str | None = Field(None) + name: str | None = Field(default=None) """The new name for this this worker. No profanity allowed!""" - paused: bool | None = Field(None) + paused: bool | None = Field(default=None) """The new state of the 'paused' var for this worker. When True, this worker will not be given any new requests.""" - team: str | None = Field(None, examples=["Direct Action"]) + team: str | None = Field(default=None, examples=["Direct Action"]) """The new team of this worker.""" @override @@ -327,18 +327,18 @@ class ModifyWorkerRequest( APIKeyAllowedInRequestMixin, WorkerRequestMixin, ): - info: str | None = Field(None, max_length=1000) + info: str | None = Field(default=None, max_length=1000) """You can optionally provide a server note which will be seen in the server details. No profanity allowed!""" - maintenance: bool | None = Field(None) + maintenance: bool | None = Field(default=None) """Set to true to put this worker into maintenance.""" - maintenance_msg: str | None = Field(None) + maintenance_msg: str | None = Field(default=None) """If maintenance is True, you can optionally provide a message to be used instead of the default maintenance message, so that the owner is informed.""" - name: str | None = Field(None, max_length=100, min_length=5) + name: str | None = Field(default=None, max_length=100, min_length=5) """When this is set, it will change the worker's name. No profanity allowed!""" - paused: bool | None = Field(None) + paused: bool | None = Field(default=None) """(Mods only) Set to true to pause this worker.""" - team: str | None = Field(None, examples=["0bed257b-e57c-4327-ac64-40cdfb1ac5e6"], max_length=36) + team: str | None = Field(default=None, examples=["0bed257b-e57c-4327-ac64-40cdfb1ac5e6"], max_length=36) """The team towards which this worker contributes kudos. It an empty string ('') is passed, it will leave the""" @override diff --git a/horde_sdk/generic_api/utils/swagger.py b/horde_sdk/generic_api/utils/swagger.py index 37d8f6b..538926a 100644 --- a/horde_sdk/generic_api/utils/swagger.py +++ b/horde_sdk/generic_api/utils/swagger.py @@ -22,7 +22,7 @@ class SwaggerModelAdditionalProperty(BaseModel): # TODO: Is this actually a recursive SwaggerModelDefinitionProperty? model_config = {"extra": "forbid"} - type_: str | None = Field(None, alias="type") + type_: str | None = Field(default=None, alias="type") description: str | None = None @@ -36,14 +36,14 @@ class SwaggerModelProperty(BaseModel): model_config = {"extra": "forbid"} - type_: str | None = Field(None, alias="type") + type_: str | None = Field(default=None, alias="type") description: str | None = None title: str | None = None default: object | None = None example: object | None = None - format_: str | None = Field(None, alias="format") + format_: str | None = Field(default=None, alias="format") enum: list[str] | None = None - ref: str | None = Field(None, alias="$ref") + ref: str | None = Field(default=None, alias="$ref") minimum: float | None = None maximum: float | None = None minLength: int | None = None @@ -59,7 +59,7 @@ class SwaggerModelRef(BaseModel): model_config = {"extra": "forbid"} - ref: str | None = Field(None, alias="$ref") + ref: str | None = Field(default=None, alias="$ref") class SwaggerModelEntry(BaseModel, ABC): @@ -75,7 +75,7 @@ class SwaggerModelDefinition(SwaggerModelEntry): model_config: ClassVar[ConfigDict] = {"extra": "forbid"} - type_: str | None = Field(None, alias="type") + type_: str | None = Field(default=None, alias="type") properties: dict[str, SwaggerModelProperty] | None = None required: list[str] | None = None @@ -179,8 +179,8 @@ class SwaggerEndpointMethodParameterSchemaProperty(BaseModel): model_config = {"extra": "forbid"} - type_: str | None = Field(None, alias="type") - format_: str | None = Field(None, alias="format") + type_: str | None = Field(default=None, alias="type") + format_: str | None = Field(default=None, alias="format") class SwaggerEndpointMethodParameterSchema(BaseModel): @@ -188,7 +188,7 @@ class SwaggerEndpointMethodParameterSchema(BaseModel): model_config = {"extra": "forbid"} - type_: str | None = Field(None, alias="type") + type_: str | None = Field(default=None, alias="type") properties: dict[str, SwaggerEndpointMethodParameterSchemaProperty] | None = None @@ -202,12 +202,12 @@ class SwaggerEndpointMethodParameter(BaseModel): description: str | None = None required: bool | None = None schema_: SwaggerEndpointMethodParameterSchema | SwaggerEndpointMethodParameterSchemaRef | None = Field( - None, + default=None, alias="schema", ) default: object | None = None - type_: str | None = Field(None, alias="type") - format_: str | None = Field(None, alias="format") + type_: str | None = Field(default=None, alias="type") + format_: str | None = Field(default=None, alias="format") class SwaggerEndpointResponseSchemaItem(BaseModel): @@ -215,7 +215,7 @@ class SwaggerEndpointResponseSchemaItem(BaseModel): # model_config = {"extra": "forbid"} - ref: str | None = Field(None, alias="$ref") + ref: str | None = Field(default=None, alias="$ref") class SwaggerEndpointResponseSchema(BaseModel): @@ -223,8 +223,8 @@ class SwaggerEndpointResponseSchema(BaseModel): # model_config = {"extra": "forbid"} - ref: str | None = Field(None, alias="$ref") - type_: str | None = Field(None, alias="type") + ref: str | None = Field(default=None, alias="$ref") + type_: str | None = Field(default=None, alias="type") items: SwaggerEndpointResponseSchemaItem | None = None @@ -234,7 +234,7 @@ class SwaggerEndpointResponse(BaseModel): model_config = {"extra": "forbid"} description: str - schema_: SwaggerEndpointResponseSchema | None = Field(None, alias="schema") + schema_: SwaggerEndpointResponseSchema | None = Field(default=None, alias="schema") class SwaggerEndpointMethod(BaseModel): @@ -244,7 +244,7 @@ class SwaggerEndpointMethod(BaseModel): summary: str | None = None description: str | None = None - operation_id: str | None = Field(None, alias="operationId") + operation_id: str | None = Field(default=None, alias="operationId") parameters: list[SwaggerEndpointMethodParameter] | None = None responses: dict[str, SwaggerEndpointResponse] | None = None tags: list[str] | None = None @@ -259,7 +259,7 @@ class SwaggerEndpointParameter(BaseModel): in_: str = Field("", alias="in") description: str | None = None required: bool | None = None - type_: str | None = Field(None, alias="type") + type_: str | None = Field(default=None, alias="type") class SwaggerEndpoint(BaseModel):