Skip to content

feat(civitai): enrich base-model discovery with github constants#4756

Open
CalamitousFelicitousness wants to merge 1 commit intodevfrom
feat/civitai-base-models
Open

feat(civitai): enrich base-model discovery with github constants#4756
CalamitousFelicitousness wants to merge 1 commit intodevfrom
feat/civitai-base-models

Conversation

@CalamitousFelicitousness
Copy link
Copy Markdown
Collaborator

Pre-scriptum

I'm going to be honest; the only reason I wasted so much time on this is that I didn't feel like admitting defeat against the absolute misery that is Civitai API. At the end of this I'm utterly ambivalent whether you consider it worth the salt to even read this ridiculous contraption.

Description

CivitAI removed enum validation from /api/v1/models?baseModels=X (now returns 200 with empty items on unknown values), which left the base-model filter dropdown empty.

Notes

Fix in two parts.

  1. Point the base_models discovery probe at /images instead of /models. /images still returns a ZodError with the full enum list (82 names at time of writing). The existing parser handles the shape unchanged.

  2. Also fetch civitai/civitai's base-model.constants.ts from GitHub and merge per-name metadata (group, ecosystem, engine, family, hidden) into a new base_models_info field on the response. The live probe remains authoritative for which names exist; GitHub provides the metadata and doubles as a fallback name list if the probe comes back empty.

Backward compatible: the existing base_models list keeps the same shape. Clients that want grouped dropdowns, hidden-flag filtering, or image/video separation can consume base_models_info instead.

The GitHub fetch has a separate 6h cache since these constants change much less often than the probes it sits alongside.

CivitAI removed enum validation from /api/v1/models?baseModels=X (now
returns 200 with empty items on unknown values), which left the
base-model filter dropdown empty. Fix in two parts.

1. Point the base_models discovery probe at /images instead of /models.
   /images still returns a ZodError with the full enum list (82 names
   at time of writing). The existing parser handles the shape unchanged.

2. Also fetch civitai/civitai's base-model.constants.ts from GitHub and
   merge per-name metadata (group, ecosystem, engine, family, hidden)
   into a new base_models_info field on the response. The live probe
   remains authoritative for which names exist; GitHub provides the
   metadata and doubles as a fallback name list if the probe comes back
   empty.

Backward compatible: the existing base_models list keeps the same
shape. Clients that want grouped dropdowns, hidden-flag filtering, or
image/video separation can consume base_models_info instead.

The GitHub fetch has a separate 6h cache since these constants change
much less often than the probes it sits alongside.
@vladmandic
Copy link
Copy Markdown
Owner

ugly but valid. only feedback is to place into separate helper py file in modules/civitai to limit the bloat to client_civitai.py

a bit off-topic, here's a generic ts:const -> python:dict converter :)
extract_base_model_config.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants