|
|
@ -196,10 +196,40 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro |
|
|
|
{ |
|
|
|
{ |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
var queryText = request.Query; |
|
|
|
var queryText = request.Query; |
|
|
|
|
|
|
|
var models = new List<CivitModel>(); |
|
|
|
|
|
|
|
CivitModelsResponse? modelsResponse = null; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
var modelsResponse = await civitApi.GetModels(request); |
|
|
|
if (!string.IsNullOrWhiteSpace(request.CommaSeparatedModelIds)) |
|
|
|
var models = modelsResponse.Items; |
|
|
|
{ |
|
|
|
|
|
|
|
// count IDs |
|
|
|
|
|
|
|
var ids = request.CommaSeparatedModelIds.Split(','); |
|
|
|
|
|
|
|
if (ids.Length > 100) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var idChunks = ids.Chunk(100); |
|
|
|
|
|
|
|
foreach (var chunk in idChunks) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
request.CommaSeparatedModelIds = string.Join(",", chunk); |
|
|
|
|
|
|
|
var chunkModelsResponse = await civitApi.GetModels(request); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (chunkModelsResponse.Items != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
models.AddRange(chunkModelsResponse.Items); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
modelsResponse = await civitApi.GetModels(request); |
|
|
|
|
|
|
|
models = modelsResponse.Items; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
modelsResponse = await civitApi.GetModels(request); |
|
|
|
|
|
|
|
models = modelsResponse.Items; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (models is null) |
|
|
|
if (models is null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Logger.Debug( |
|
|
|
Logger.Debug( |
|
|
@ -241,13 +271,13 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro |
|
|
|
InsertedAt = DateTimeOffset.UtcNow, |
|
|
|
InsertedAt = DateTimeOffset.UtcNow, |
|
|
|
Request = request, |
|
|
|
Request = request, |
|
|
|
Items = models, |
|
|
|
Items = models, |
|
|
|
Metadata = modelsResponse.Metadata |
|
|
|
Metadata = modelsResponse?.Metadata |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
UpdateModelCards(models, isInfiniteScroll); |
|
|
|
UpdateModelCards(models, isInfiniteScroll); |
|
|
|
|
|
|
|
|
|
|
|
NextPageCursor = modelsResponse.Metadata?.NextCursor; |
|
|
|
NextPageCursor = modelsResponse?.Metadata?.NextCursor; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (OperationCanceledException) |
|
|
|
catch (OperationCanceledException) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -428,12 +458,14 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro |
|
|
|
{ |
|
|
|
{ |
|
|
|
var connectedModels = CheckpointFile |
|
|
|
var connectedModels = CheckpointFile |
|
|
|
.GetAllCheckpointFiles(settingsManager.ModelsDirectory) |
|
|
|
.GetAllCheckpointFiles(settingsManager.ModelsDirectory) |
|
|
|
.Where(c => c.IsConnectedModel); |
|
|
|
.Where(c => c.IsConnectedModel) |
|
|
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
modelRequest.CommaSeparatedModelIds = string.Join( |
|
|
|
modelRequest.CommaSeparatedModelIds = string.Join( |
|
|
|
",", |
|
|
|
",", |
|
|
|
connectedModels.Select(c => c.ConnectedModel!.ModelId).GroupBy(m => m).Select(g => g.First()) |
|
|
|
connectedModels.Select(c => c.ConnectedModel!.ModelId).GroupBy(m => m).Select(g => g.First()) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
modelRequest.Sort = null; |
|
|
|
modelRequest.Sort = null; |
|
|
|
modelRequest.Period = null; |
|
|
|
modelRequest.Period = null; |
|
|
|
} |
|
|
|
} |
|
|
|