feat(civitai): enrich base-model discovery with github constants#4756
Open
CalamitousFelicitousness wants to merge 1 commit intodevfrom
Open
feat(civitai): enrich base-model discovery with github constants#4756CalamitousFelicitousness wants to merge 1 commit intodevfrom
CalamitousFelicitousness wants to merge 1 commit intodevfrom
Conversation
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.
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 :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.
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.