mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
fix(civitai): tolerate null availability, expose early access fields
The /model-versions endpoint now serializes availability as null, which failed str validation and turned every version lookup into a 404. Coerce null to the default like the creator username validator already does. Pass through earlyAccessEndsAt and earlyAccessConfig so clients can see that a download requires a Buzz purchase before requesting the file.
This commit is contained in:
@@ -58,6 +58,8 @@ class CivitVersion(BaseModel):
|
||||
base_model: str = Field("Unknown", alias="baseModel")
|
||||
published_at: str | None = Field(None, alias="publishedAt")
|
||||
availability: str = "Unknown"
|
||||
early_access_ends_at: str | None = Field(None, alias="earlyAccessEndsAt")
|
||||
early_access_config: dict | None = Field(None, alias="earlyAccessConfig")
|
||||
description: str | None = None
|
||||
trained_words: list[str] = Field(default_factory=list, alias="trainedWords")
|
||||
stats: CivitStats = Field(default_factory=CivitStats)
|
||||
@@ -66,6 +68,13 @@ class CivitVersion(BaseModel):
|
||||
nsfw_level: int = Field(0, alias="nsfwLevel")
|
||||
download_url: str = Field("", alias="downloadUrl")
|
||||
|
||||
@validator('availability', pre=True)
|
||||
def coerce_null_availability(cls, v): # pylint: disable=no-self-argument
|
||||
# /model-versions/{id} serializes availability as null, which failed
|
||||
# str validation and turned every version lookup into a 404. Fall back
|
||||
# to the default instead of rejecting the whole version.
|
||||
return "Unknown" if v in (None, "") else v
|
||||
|
||||
|
||||
class CivitCreator(BaseModel):
|
||||
class Config:
|
||||
|
||||
Reference in New Issue
Block a user