-
-
Notifications
You must be signed in to change notification settings - Fork 559
v2.15.8 #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
v2.15.8 #1642
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c6ff87
Merge pull request #1239 from ionite34/fix/civit-reliability-and-swar…
mohnjiles 7373463
fix chagenlog merge
mohnjiles 857224f
Merge pull request #1240 from ionite34/backport/main/pr-1239
mohnjiles 351bb23
Merge branch 'main' into merge-LykosAI-StabilityMatrix-Dev-main-to-ma…
ionite34 3a75495
Merge pull request #1241 from ionite34/merge-LykosAI-StabilityMatrix-…
ionite34 3ce6497
Merge branch 'main' of https://github.com/LykosAI/StabilityMatrix-Dev…
mohnjiles 2bc3e30
Merge pull request #1244 from ionite34/downmerg-from-public
mohnjiles 2b5d1dd
Merge pull request #1246 from ionite34/another-shoutout-chagenlog
mohnjiles c37b736
Fix chagenlog
mohnjiles d0377b9
Merge pull request #1247 from ionite34/backport/main/pr-1246
mohnjiles 8aa43cd
Merge pull request #1248 from ionite34/update-comfy-zluda-args
mohnjiles 6287bba
fix chagenlog
mohnjiles f0239bb
Merge pull request #1249 from ionite34/backport/main/pr-1248
mohnjiles ba2d72b
add new pioneers
mohnjiles 256185d
Merge pull request #1251 from ionite34/chagenlog-update
mohnjiles bdb77d5
Merge branch 'main' of https://github.com/LykosAI/StabilityMatrix-Dev
mohnjiles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,65 @@ ILiteDbContext dbContext | |
| { | ||
| private const string CacheId = "BaseModelTypes"; | ||
| private static readonly TimeSpan CacheExpiration = TimeSpan.FromHours(24); | ||
| private const string LegacyBaseModelListProbe = "gimmethelist"; | ||
| private static readonly IReadOnlyList<string> KnownVisibleBaseModelTypes = | ||
| [ | ||
| "Anima", | ||
| "AuraFlow", | ||
| "Chroma", | ||
| "CogVideoX", | ||
| "Flux.1 D", | ||
| "Flux.1 Kontext", | ||
| "Flux.1 Krea", | ||
| "Flux.1 S", | ||
| "Flux.2 D", | ||
| "Flux.2 Klein 4B", | ||
| "Flux.2 Klein 4B-base", | ||
| "Flux.2 Klein 9B", | ||
| "Flux.2 Klein 9B-base", | ||
| "Grok", | ||
| "HiDream", | ||
| "Hunyuan 1", | ||
| "Hunyuan Video", | ||
| "Illustrious", | ||
| "Kolors", | ||
| "LTXV", | ||
| "LTXV 2.3", | ||
| "LTXV2", | ||
| "Lumina", | ||
| "Mochi", | ||
| "NoobAI", | ||
| "Other", | ||
| "PixArt E", | ||
| "PixArt a", | ||
| "Pony", | ||
| "Pony V7", | ||
| "Qwen", | ||
| "Qwen 2", | ||
| "SD 1.4", | ||
| "SD 1.5", | ||
| "SD 1.5 Hyper", | ||
| "SD 1.5 LCM", | ||
| "SD 2.0", | ||
| "SD 2.1", | ||
| "SDXL 1.0", | ||
| "SDXL Hyper", | ||
| "SDXL Lightning", | ||
| "Upscaler", | ||
| "Wan Image 2.7", | ||
| "Wan Video 1.3B t2v", | ||
| "Wan Video 14B i2v 480p", | ||
| "Wan Video 14B i2v 720p", | ||
| "Wan Video 14B t2v", | ||
| "Wan Video 2.2 I2V-A14B", | ||
| "Wan Video 2.2 T2V-A14B", | ||
| "Wan Video 2.2 TI2V-5B", | ||
| "Wan Video 2.5 I2V", | ||
| "Wan Video 2.5 T2V", | ||
| "Wan Video 2.7", | ||
| "ZImageBase", | ||
| "ZImageTurbo", | ||
| ]; | ||
|
|
||
| /// <summary> | ||
| /// Gets the list of base model types, using cache if available and not expired | ||
|
|
@@ -39,15 +98,11 @@ public async Task<List<string>> GetBaseModelTypes(bool forceRefresh = false, boo | |
| { | ||
| if (civitBaseModels.Count <= 0) | ||
| { | ||
| var baseModelsResponse = await civitApi.GetBaseModelList(); | ||
| var jsonContent = await baseModelsResponse.Content.ReadAsStringAsync(); | ||
| var baseModels = JsonNode.Parse(jsonContent); | ||
| civitBaseModels = | ||
| await TryGetBaseModelsFromEnumsEndpoint() ?? await TryGetLegacyBaseModelList() ?? []; | ||
|
|
||
| var innerJson = baseModels?["error"]?["message"]?.GetValue<string>(); | ||
| var jArray = JsonNode.Parse(innerJson).AsArray(); | ||
| var baseModelValues = jArray[0]?["errors"]?[0]?[0]?["values"]?.AsArray(); | ||
|
|
||
| civitBaseModels = baseModelValues?.GetValues<string>().ToList() ?? []; | ||
| civitBaseModels = | ||
| civitBaseModels.Count > 0 ? civitBaseModels : GetKnownVisibleBaseModelTypes(); | ||
|
|
||
| // Cache the results | ||
| var cacheEntry = new CivitBaseModelTypeCacheEntry | ||
|
|
@@ -60,27 +115,18 @@ public async Task<List<string>> GetBaseModelTypes(bool forceRefresh = false, boo | |
| await dbContext.UpsertCivitBaseModelTypeCacheEntry(cacheEntry); | ||
| } | ||
|
|
||
| if (includeAllOption) | ||
| { | ||
| civitBaseModels.Insert(0, CivitBaseModelType.All.ToString()); | ||
| } | ||
|
|
||
| // Filter and sort results | ||
| var filteredResults = civitBaseModels | ||
| .Where(s => !s.Equals("odor", StringComparison.OrdinalIgnoreCase)) | ||
| .OrderBy(s => s) | ||
| .ToList(); | ||
|
|
||
| return filteredResults; | ||
| return NormalizeBaseModelTypes(civitBaseModels, includeAllOption); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| logger.LogError(e, "Failed to get base model list"); | ||
|
|
||
| // Return cached results if available, even if expired | ||
| var expiredCache = await dbContext.GetCivitBaseModelTypeCacheEntry(CacheId); | ||
| return expiredCache?.ModelTypes | ||
| ?? Enum.GetValues<CivitBaseModelType>().Select(b => b.GetStringValue()).ToList(); | ||
| return NormalizeBaseModelTypes( | ||
| expiredCache?.ModelTypes ?? GetKnownVisibleBaseModelTypes(), | ||
| includeAllOption | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -91,4 +137,82 @@ public void ClearCache() | |
| { | ||
| dbContext.CivitBaseModelTypeCache.DeleteAllAsync(); | ||
| } | ||
|
|
||
| private async Task<List<string>?> TryGetBaseModelsFromEnumsEndpoint() | ||
| { | ||
| try | ||
| { | ||
| var enumsResponse = await civitApi.GetEnums(); | ||
| var baseModels = enumsResponse?.ActiveBaseModel ?? enumsResponse?.BaseModel; | ||
|
|
||
| if (baseModels is { Count: > 0 }) | ||
| { | ||
| return baseModels; | ||
| } | ||
|
|
||
| logger.LogInformation( | ||
| "CivitAI enums endpoint returned no base models; falling back to legacy/base list" | ||
| ); | ||
| return null; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| logger.LogInformation(ex, "CivitAI enums endpoint failed; falling back to legacy/base list"); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| private async Task<List<string>?> TryGetLegacyBaseModelList() | ||
| { | ||
| var baseModelsResponse = await civitApi.GetBaseModelList(); | ||
| var jsonContent = await baseModelsResponse.Content.ReadAsStringAsync(); | ||
| return TryParseLegacyBaseModelList(jsonContent); | ||
| } | ||
|
|
||
| private List<string>? TryParseLegacyBaseModelList(string jsonContent) | ||
| { | ||
| var baseModels = JsonNode.Parse(jsonContent); | ||
| var innerJson = baseModels?["error"]?["message"]?.GetValue<string>(); | ||
| if (string.IsNullOrWhiteSpace(innerJson)) | ||
| { | ||
| logger.LogInformation( | ||
| "CivitAI base model probe value '{Probe}' no longer returns the legacy validation payload; using built-in base model list", | ||
| LegacyBaseModelListProbe | ||
| ); | ||
| return null; | ||
| } | ||
|
|
||
| var jArray = JsonNode.Parse(innerJson)?.AsArray(); | ||
| var baseModelValues = jArray?[0]?["errors"]?[0]?[0]?["values"]?.AsArray(); | ||
| return baseModelValues?.GetValues<string>().ToList(); | ||
| } | ||
|
|
||
| private static List<string> GetKnownVisibleBaseModelTypes() | ||
| { | ||
| return KnownVisibleBaseModelTypes.ToList(); | ||
| } | ||
|
|
||
| private static List<string> NormalizeBaseModelTypes( | ||
| IEnumerable<string>? baseModels, | ||
| bool includeAllOption | ||
| ) | ||
| { | ||
| var normalized = (baseModels ?? []) | ||
| .Where(s => !string.IsNullOrWhiteSpace(s)) | ||
| .Where(s => !s.Equals("odor", StringComparison.OrdinalIgnoreCase)) | ||
| .Distinct(StringComparer.OrdinalIgnoreCase) | ||
| .OrderBy(s => s) | ||
| .ToList(); | ||
|
|
||
| normalized.RemoveAll(s => | ||
| s.Equals(CivitBaseModelType.All.ToString(), StringComparison.OrdinalIgnoreCase) | ||
| ); | ||
|
|
||
| if (includeAllOption) | ||
| { | ||
| normalized.Insert(0, CivitBaseModelType.All.ToString()); | ||
| } | ||
|
|
||
| return normalized; | ||
| } | ||
|
Comment on lines
+195
to
+217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CivitBaseModelType.All.ToString() is called multiple times, including inside a RemoveAll predicate. It is more efficient to evaluate this once and store it in a local variable. private static List<string> NormalizeBaseModelTypes(
IEnumerable<string>? baseModels,
bool includeAllOption
)
{
var allOptionString = CivitBaseModelType.All.ToString();
var normalized = (baseModels ?? [])
.Where(s => !string.IsNullOrWhiteSpace(s))
.Where(s => !s.Equals("odor", StringComparison.OrdinalIgnoreCase))
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(s => s)
.ToList();
normalized.RemoveAll(s =>
s.Equals(allOptionString, StringComparison.OrdinalIgnoreCase)
);
if (includeAllOption)
{
normalized.Insert(0, allOptionString);
}
return normalized;
} |
||
| } | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entry for issue #1608 is a duplicate of the one on line 14. Please remove it.