Skip to content

Commit 0a2f509

Browse files
authored
Merge pull request #1110 from ionite34/backport/main/pr-1109
[dev to main] backport: update base model parsing from error response cuz civit changed response model (1109)
2 parents 647f19b + f7a739e commit 0a2f509

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
2323
- Fixed [#1305](https://github.com/LykosAI/StabilityMatrix/issues/1305) - FluxGym installing incorrect packages for Blackwell GPUs
2424
- Fixed [#1316](https://github.com/LykosAI/StabilityMatrix/issues/1316) - Errors when installing Triton & SageAttention
2525
- Fixed "directory is not empty" error when updating packages with symlinks
26+
- Fixed missing base model types in the Checkpoint Manager & Civitai Model Browser
2627

2728
## v2.14.2
2829
### Changed

StabilityMatrix.Avalonia/Services/CivitBaseModelTypeService.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.Logging;
44
using StabilityMatrix.Core.Api;
55
using StabilityMatrix.Core.Database;
6+
using StabilityMatrix.Core.Extensions;
67
using StabilityMatrix.Core.Models.Api;
78
using StabilityMatrix.Core.Models.Database;
89

@@ -42,18 +43,18 @@ public async Task<List<string>> GetBaseModelTypes(bool forceRefresh = false, boo
4243
var jsonContent = await baseModelsResponse.Content.ReadAsStringAsync();
4344
var baseModels = JsonNode.Parse(jsonContent);
4445

45-
var jArray =
46-
baseModels?["error"]?["issues"]?[0]?["unionErrors"]?[0]?["issues"]?[0]?["options"]
47-
as JsonArray;
46+
var innerJson = baseModels?["error"]?["message"]?.GetValue<string>();
47+
var jArray = JsonNode.Parse(innerJson).AsArray();
48+
var baseModelValues = jArray[0]?["errors"]?[0]?[0]?["values"]?.AsArray();
4849

49-
civitBaseModels = jArray?.GetValues<string>().ToList() ?? [];
50+
civitBaseModels = baseModelValues?.GetValues<string>().ToList() ?? [];
5051

5152
// Cache the results
5253
var cacheEntry = new CivitBaseModelTypeCacheEntry
5354
{
5455
Id = CacheId,
5556
ModelTypes = civitBaseModels,
56-
CreatedAt = DateTimeOffset.UtcNow
57+
CreatedAt = DateTimeOffset.UtcNow,
5758
};
5859

5960
await dbContext.UpsertCivitBaseModelTypeCacheEntry(cacheEntry);
@@ -78,7 +79,8 @@ public async Task<List<string>> GetBaseModelTypes(bool forceRefresh = false, boo
7879

7980
// Return cached results if available, even if expired
8081
var expiredCache = await dbContext.GetCivitBaseModelTypeCacheEntry(CacheId);
81-
return expiredCache?.ModelTypes ?? [];
82+
return expiredCache?.ModelTypes
83+
?? Enum.GetValues<CivitBaseModelType>().Select(b => b.GetStringValue()).ToList();
8284
}
8385
}
8486

0 commit comments

Comments
 (0)