-
-
Notifications
You must be signed in to change notification settings - Fork 551
Expand file tree
/
Copy pathDesignData.cs
More file actions
1622 lines (1484 loc) · 68.2 KB
/
DesignData.cs
File metadata and controls
1622 lines (1484 loc) · 68.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using AvaloniaEdit.Document;
using AvaloniaEdit.Utils;
using DynamicData.Binding;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Semver;
using StabilityMatrix.Avalonia.Controls.CodeCompletion;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.TagCompletion;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser;
using StabilityMatrix.Avalonia.ViewModels.CheckpointManager;
using StabilityMatrix.Avalonia.ViewModels.Controls;
using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Avalonia.ViewModels.Inference.Video;
using StabilityMatrix.Avalonia.ViewModels.OutputsPage;
using StabilityMatrix.Avalonia.ViewModels.PackageManager;
using StabilityMatrix.Avalonia.ViewModels.Progress;
using StabilityMatrix.Avalonia.ViewModels.Settings;
using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Cache;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Core.Models.Api.CivitTRPC;
using StabilityMatrix.Core.Models.Api.Comfy;
using StabilityMatrix.Core.Models.Api.OpenArt;
using StabilityMatrix.Core.Models.Api.OpenModelsDb;
using StabilityMatrix.Core.Models.Database;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.PackageModification;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Models.Packages.Extensions;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Update;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Core.Updater;
using CivitAiBrowserViewModel = StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser.CivitAiBrowserViewModel;
using HuggingFacePageViewModel = StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser.HuggingFacePageViewModel;
using MainPackageManagerViewModel = StabilityMatrix.Avalonia.ViewModels.PackageManager.MainPackageManagerViewModel;
namespace StabilityMatrix.Avalonia.DesignData;
[Localizable(false)]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static class DesignData
{
[NotNull]
public static IServiceProvider? Services { get; set; }
private static bool isInitialized;
// This needs to be static method instead of static constructor
// or else Avalonia analyzers won't work.
public static void Initialize()
{
if (isInitialized)
throw new InvalidOperationException("DesignData is already initialized.");
var services = App.ConfigureServices(disableMessagePipeInterprocess: true);
var activePackageId = Guid.NewGuid();
services.AddSingleton<ISettingsManager, MockSettingsManager>(_ => new MockSettingsManager
{
Settings =
{
InstalledPackages = new List<InstalledPackage>
{
new()
{
Id = activePackageId,
DisplayName = "My Installed Package",
PackageName = "framepack",
Version = new InstalledPackageVersion { InstalledReleaseVersion = "v1.0.0" },
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now,
},
new()
{
Id = Guid.NewGuid(),
DisplayName = "Comfy Diffusion WebUI Dev Branch Long Name",
PackageName = "ComfyUI",
Version = new InstalledPackageVersion
{
InstalledBranch = "master",
InstalledCommitSha = "abc12uwu345568972abaedf7g7e679a98879e879f87ga8",
},
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now,
},
new()
{
Id = Guid.NewGuid(),
DisplayName = "Running Comfy",
PackageName = "ComfyUI",
Version = new InstalledPackageVersion
{
InstalledBranch = "master",
InstalledCommitSha = "abc12uwu345568972abaedf7g7e679a98879e879f87ga8",
},
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now,
},
},
ActiveInstalledPackageId = activePackageId,
},
});
// General services
services
.AddLogging()
.AddSingleton<IPackageFactory, PackageFactory>()
.AddSingleton<IUpdateHelper, UpdateHelper>()
.AddSingleton<ModelFinder>()
.AddSingleton<SharedState>();
// Mock services
services
.AddSingleton(Substitute.For<INotificationService>())
.AddSingleton(Substitute.For<ISharedFolders>())
.AddSingleton(Substitute.For<IDownloadService>())
.AddSingleton(Substitute.For<IHttpClientFactory>())
.AddSingleton(Substitute.For<IApiFactory>())
.AddSingleton(Substitute.For<IDiscordRichPresenceService>())
.AddSingleton(Substitute.For<ITrackedDownloadService>())
.AddSingleton(Substitute.For<ILiteDbContext>())
.AddSingleton(Substitute.For<IAccountsService>())
.AddSingleton<IInferenceClientManager, MockInferenceClientManager>()
.AddSingleton<ICompletionProvider, MockCompletionProvider>()
.AddSingleton<IModelIndexService, MockModelIndexService>()
.AddSingleton<IImageIndexService, MockImageIndexService>()
.AddSingleton<IMetadataImportService, MetadataImportService>();
// Placeholder services that nobody should need during design time
services
.AddSingleton<IPyRunner>(_ => null!)
.AddSingleton<ILiteDbContext>(_ => null!)
.AddSingleton<ICivitApi>(_ => null!)
.AddSingleton<IGithubApiCache>(_ => null!)
.AddSingleton<ITokenizerProvider>(_ => null!)
.AddSingleton<IPrerequisiteHelper>(_ => null!)
.AddSingleton<IPyPiApi>(_ => null!)
.AddSingleton<IPyPiCache>(_ => null!);
// Override Launch page with mock
services.Remove(ServiceDescriptor.Singleton<LaunchPageViewModel, LaunchPageViewModel>());
services.AddSingleton<LaunchPageViewModel, MockLaunchPageViewModel>();
Services = services.BuildServiceProvider();
var dialogFactory = Services.GetRequiredService<IServiceManager<ViewModelBase>>();
var settingsManager = Services.GetRequiredService<ISettingsManager>();
var downloadService = Services.GetRequiredService<IDownloadService>();
var modelFinder = Services.GetRequiredService<ModelFinder>();
var packageFactory = Services.GetRequiredService<IPackageFactory>();
var notificationService = Services.GetRequiredService<INotificationService>();
var modelImportService = Services.GetRequiredService<IMetadataImportService>();
LaunchOptionsViewModel = Services.GetRequiredService<LaunchOptionsViewModel>();
LaunchOptionsViewModel.Cards = new[]
{
LaunchOptionCard.FromDefinition(
new LaunchOptionDefinition
{
Name = "Host",
Type = LaunchOptionType.String,
Description = "The host name for the Web UI",
DefaultValue = "localhost",
Options = { "--host" },
}
),
LaunchOptionCard.FromDefinition(
new LaunchOptionDefinition
{
Name = "API",
Type = LaunchOptionType.Bool,
Options = { "--api" },
}
),
};
LaunchOptionsViewModel.UpdateFilterCards();
NewInstallerDialogViewModel = Services.GetRequiredService<PackageInstallBrowserViewModel>();
// NewInstallerDialogViewModel.InferencePackages = new ObservableCollectionExtended<BasePackage>(
// packageFactory.GetPackagesByType(PackageType.SdInference).OrderBy(p => p.InstallerSortOrder)
// );
// NewInstallerDialogViewModel.TrainingPackages = new ObservableCollection<BasePackage>(
// packageFactory.GetPackagesByType(PackageType.SdTraining).OrderBy(p => p.InstallerSortOrder)
// );
PackageInstallDetailViewModel = new PackageInstallDetailViewModel(
packageFactory.GetAllAvailablePackages().FirstOrDefault() as BaseGitPackage,
settingsManager,
notificationService,
null,
null,
null,
packageFactory,
null,
null
);
PackageInstallDetailViewModel.AvailablePythonVersions = new ObservableCollection<UvPythonInfo>(
[
new UvPythonInfo(
PyInstallationManager.Python_3_10_17,
"C:\\SMData\\Data\\Data\\Assets\\Python\\cpython-3.11.12-windows-x86_64-none",
true,
"cpython",
"x86_64",
"windows",
"cpython-3.10.17-windows-x86_64-none",
"default",
"none"
),
new UvPythonInfo(
PyInstallationManager.Python_3_12_10,
null,
false,
"cpython",
"x86_64",
"windows",
"guh I can't be bothered",
"freethreaded",
"none"
),
]
);
/*ObservableCacheEx.AddOrUpdate(
OldCheckpointsPageViewModel.CheckpointFoldersCache,
new CheckpointFolder[]
{
new(settingsManager, downloadService, modelFinder, notificationService, modelImportService)
{
DirectoryPath = "Models/StableDiffusion",
DisplayedCheckpointFiles = new ObservableCollectionExtended<CheckpointFile>()
{
new()
{
FilePath = "~/Models/StableDiffusion/electricity-light.safetensors",
Title = "Auroral Background",
PreviewImagePath =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/"
+ "78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
UpdateAvailable = true,
ConnectedModel = new ConnectedModelInfo
{
VersionName = "Lightning Auroral",
BaseModel = "SD 1.5",
ModelName = "Auroral Background",
ModelType = CivitModelType.Model,
FileMetadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = CivitModelFpType.fp16,
Size = CivitModelSize.pruned,
},
TrainedWords = ["aurora", "lightning"]
}
},
new() { FilePath = "~/Models/Lora/model.safetensors", Title = "Some model" },
},
},
new(settingsManager, downloadService, modelFinder, notificationService, modelImportService)
{
Title = "Lora",
DirectoryPath = "Packages/Lora",
DisplayedCheckpointFiles = new ObservableCollectionExtended<CheckpointFile>
{
new() { FilePath = "~/Models/Lora/lora_v2.pt", Title = "Best Lora v2", }
}
}
}
);*/
CivitAiBrowserViewModel.ModelCards = new ObservableCollectionExtended<CheckpointBrowserCardViewModel>
{
dialogFactory.Get<CheckpointBrowserCardViewModel>(vm =>
{
vm.CivitModel = new CivitModel
{
Name = "BB95 Furry Mix",
Description = "A furry mix of BB95",
Stats = new CivitModelStats { Rating = 3.5, RatingCount = 24 },
ModelVersions = [new() { Name = "v1.2.2-Inpainting" }],
Creator = new CivitCreator
{
Image = "https://gravatar.com/avatar/fe74084ae8a081dc2283f5bde4736756ad?f=y&d=retro",
Username = "creator-1",
},
};
}),
dialogFactory.Get<CheckpointBrowserCardViewModel>(vm =>
{
vm.CivitModel = new CivitModel
{
Name = "Another Model",
Description = "A mix of example",
Stats = new CivitModelStats { Rating = 5, RatingCount = 3500 },
ModelVersions =
[
new()
{
Name = "v1.2.2-Inpainting",
Images = new List<CivitImage>
{
new()
{
NsfwLevel = 1,
Url =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/"
+ "78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
},
},
},
],
Creator = new CivitCreator
{
Image = "https://gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?f=y&d=retro",
Username = "creator-2",
},
};
}),
};
CheckpointsPageViewModel.Categories = new ObservableCollectionExtended<CheckpointCategory>
{
new()
{
Name = "Category 1",
Path = "path1",
SubDirectories = [new CheckpointCategory { Name = "SubCategory 1", Path = "path3" }],
},
new() { Name = "Category 2", Path = "path2" },
};
CheckpointsPageViewModel.Models = new ObservableCollectionExtended<CheckpointFileViewModel>()
{
new(
settingsManager,
new MockModelIndexService(),
notificationService,
downloadService,
dialogFactory,
null,
new LocalModelFile
{
SharedFolderType = SharedFolderType.StableDiffusion,
RelativePath = "~/Models/StableDiffusion/electricity-light.safetensors",
PreviewImageFullPath =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/"
+ "78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
HasUpdate = true,
ConnectedModelInfo = new ConnectedModelInfo
{
VersionName = "Lightning Auroral",
BaseModel = "SD 1.5",
ModelName = "Auroral Background",
ModelType = CivitModelType.Model,
FileMetadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = "fp16",
Size = "pruned",
},
TrainedWords = ["aurora", "lightning"],
},
}
),
new(
settingsManager,
new MockModelIndexService(),
notificationService,
downloadService,
dialogFactory,
null,
new LocalModelFile
{
RelativePath = "~/Models/Lora/model.safetensors",
SharedFolderType = SharedFolderType.StableDiffusion,
}
),
};
var packageInstall = new PackageInstallProgressItemViewModel(
new PackageModificationRunner
{
CurrentProgress = new ProgressReport(0.5f, "Installing package...", "Installing... 50%"),
ModificationCompleteMessage = "Package installed successfully",
}
)
{
Progress = new ContentDialogProgressViewModelBase
{
Value = 50,
IsIndeterminate = false,
Text = "UwU Install",
Description = "Installing...",
},
};
ProgressManagerViewModel.ProgressItems.AddRange(
[
new ProgressItemViewModel(
new ProgressItem(
Guid.NewGuid(),
"Test File.exe",
new ProgressReport(0.5f, "Downloading...")
)
),
new MockDownloadProgressItemViewModel(
"Very Long Test File Name Need Even More Longness Thanks That's pRobably good 2.exe"
),
new MockDownloadProgressItemViewModel(
"Very Long Test File Name Need Even More Longness Thanks That's pRobably good 2.exe"
)
{
Progress = new ContentDialogProgressViewModelBase
{
Value = 50,
IsIndeterminate = false,
Text = "Waiting on other downloads to finish",
Description = "Waiting on other downloads to finish",
},
},
packageInstall,
]
);
UpdateViewModel = Services.GetRequiredService<UpdateViewModel>();
UpdateViewModel.CurrentVersionText = "v2.0.0";
UpdateViewModel.NewVersionText = "v2.0.1";
UpdateViewModel.ReleaseNotes =
"## v2.0.1\n- Fixed a bug\n- Added a feature\n- Removed a feature\n - Did some `--code` stuff";
isInitialized = true;
}
[NotNull]
public static PackageInstallBrowserViewModel? NewInstallerDialogViewModel { get; private set; }
[NotNull]
public static PackageInstallDetailViewModel? PackageInstallDetailViewModel { get; private set; }
[NotNull]
public static LaunchOptionsViewModel? LaunchOptionsViewModel { get; private set; }
[NotNull]
public static UpdateViewModel? UpdateViewModel { get; private set; }
public static IServiceManager<ViewModelBase> DialogFactory =>
Services.GetRequiredService<IServiceManager<ViewModelBase>>();
public static MainWindowViewModel MainWindowViewModel =>
Services.GetRequiredService<MainWindowViewModel>();
public static FirstLaunchSetupViewModel FirstLaunchSetupViewModel =>
Services.GetRequiredService<FirstLaunchSetupViewModel>();
public static NotificationBannerViewModel NotificationBannerViewModel =>
DialogFactory.Get<NotificationBannerViewModel>(vm =>
{
vm.Show(
new Core.Models.Notifications.AppNotification
{
Id = "test",
Type = Core.Models.Notifications.AppNotificationType.Banner,
Priority = Core.Models.Notifications.AppNotificationPriority.Normal,
Message = new Dictionary<string, string> { { "en", "This is a test notification." } },
Style = new Core.Models.Notifications.AppNotificationStyle { Variant = "info" },
Action = new Core.Models.Notifications.AppNotificationAction
{
Type = Core.Models.Notifications.AppNotificationActionType.Url,
Label = new Dictionary<string, string> { { "en", "Learn More" } },
Url = "https://example.com",
},
}
);
});
public static LaunchPageViewModel LaunchPageViewModel =>
Services.GetRequiredService<LaunchPageViewModel>();
public static HuggingFacePageViewModel HuggingFacePageViewModel =>
Services.GetRequiredService<HuggingFacePageViewModel>();
public static DirectUrlImportViewModel DirectUrlImportViewModel =>
Services.GetRequiredService<DirectUrlImportViewModel>();
public static NewOneClickInstallViewModel NewOneClickInstallViewModel =>
Services.GetRequiredService<NewOneClickInstallViewModel>();
public static RecommendedModelsViewModel RecommendedModelsViewModel =>
DialogFactory.Get<RecommendedModelsViewModel>(vm =>
{
// Populate the single RecommendedModels collection for design time
vm.RecommendedModels.AddRange(
[
new RecommendedModelItemViewModel
{
CivitModel = new CivitModel { Name = "BB95 Furry Mix", Id = 1 }, // Added Id for clarity
ModelVersion = new CivitModelVersion
{
Id = 101, // Added Id for clarity
Name = "v1.0", // Example version name
BaseModel = "SD 1.5", // Example base model
Stats = new CivitModelStats { Rating = 4.5, RatingCount = 124 },
Files = [new CivitFile { Type = CivitFileType.Model }], // Example file
Images =
[
new CivitImage
{
Type = "image", // Ensure type is set
Url =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
},
],
},
Author = "by bb95",
},
new RecommendedModelItemViewModel
{
CivitModel = new CivitModel { Name = "DreamShaper XL", Id = 2 },
ModelVersion = new CivitModelVersion
{
Id = 201,
Name = "v2.1 Turbo",
BaseModel = "SDXL 1.0",
Stats = new CivitModelStats { Rating = 4.8, RatingCount = 589 },
Files = [new CivitFile { Type = CivitFileType.Model, IsPrimary = true }],
Images =
[
new CivitImage
{
Type = "image",
// Placeholder - replace with an actual relevant image URL if possible
Url =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/0cf3e133-4dde-458b-8a70-7451a3361472/width=450/00016-3919014893.jpeg",
},
],
},
Author = "by Lykon",
},
new RecommendedModelItemViewModel
{
CivitModel = new CivitModel { Name = "Another Model SD1.5", Id = 3 },
ModelVersion = new CivitModelVersion
{
Id = 301,
Name = "Final",
BaseModel = "SD 1.5",
Stats = new CivitModelStats { Rating = 4.2, RatingCount = 99 },
Files = [new CivitFile { Type = CivitFileType.Model }],
Images = [new CivitImage { Type = "image", Url = Assets.NoImage.ToString() }], // Use placeholder
},
Author = "by Creator3",
},
// Add more items as needed for design-time preview
]
);
});
public static OutputsPageViewModel OutputsPageViewModel
{
get
{
var vm = Services.GetRequiredService<OutputsPageViewModel>();
vm.Outputs = new ObservableCollectionExtended<OutputImageViewModel>
{
new(
new LocalImageFile
{
AbsolutePath =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
ImageType = LocalImageFileType.TextToImage,
}
),
};
vm.Categories = new ObservableCollectionExtended<TreeViewDirectory>
{
new()
{
Name = "Category 1",
Path = "path1",
SubDirectories = [new TreeViewDirectory { Name = "SubCategory 1", Path = "path3" }],
},
new() { Name = "Category 2", Path = "path2" },
};
return vm;
}
}
public static MainPackageManagerViewModel MainPackageManagerViewModel
{
get
{
var settings = Services.GetRequiredService<ISettingsManager>();
var vm = Services.GetRequiredService<MainPackageManagerViewModel>();
vm.SetPackages(settings.Settings.InstalledPackages);
vm.SetUnknownPackages(
new InstalledPackage[]
{
UnknownInstalledPackage.FromDirectoryName("sd-unknown-with-long-name"),
}
);
vm.PackageCards[0].IsUpdateAvailable = true;
return vm;
}
}
public static PackageExtensionBrowserViewModel PackageExtensionBrowserViewModel =>
DialogFactory.Get<PackageExtensionBrowserViewModel>(vm =>
{
vm.AddExtensions(
[
new PackageExtension
{
Author = "123",
Title = "Cool Extension",
Description = "This is an interesting extension",
Reference = new Uri("https://github.com/LykosAI/StabilityMatrix"),
Files = [new Uri("https://github.com/LykosAI/StabilityMatrix")],
},
new PackageExtension
{
Author = "123",
Title = "Cool Extension",
Description = "This is an interesting extension",
Reference = new Uri("https://github.com/LykosAI/StabilityMatrix"),
Files = [new Uri("https://github.com/LykosAI/StabilityMatrix")],
},
],
[
new InstalledPackageExtension
{
GitRepositoryUrl = "https://github.com/LykosAI/StabilityMatrix",
Paths = [new DirectoryPath("example-dir")],
},
new InstalledPackageExtension { Paths = [new DirectoryPath("example-dir-2")] },
]
);
vm.AddExtensionPacks(
[
new ExtensionPack
{
Name = "Test Pack",
PackageType = "ComfyUI",
Extensions =
[
new SavedPackageExtension
{
PackageExtension = new PackageExtension
{
Author = "TestAuthor",
Title = "Test",
Reference = new Uri("https://github.com/LykosAI/StabilityMatrix"),
Files = [new Uri("https://github.com/LykosAI/StabilityMatrix")],
},
Version = new PackageExtensionVersion
{
Branch = "main",
CommitSha = "abcd123",
},
},
],
},
]
);
});
public static CheckpointsPageViewModel CheckpointsPageViewModel =>
Services.GetRequiredService<CheckpointsPageViewModel>();
public static SettingsViewModel SettingsViewModel => Services.GetRequiredService<SettingsViewModel>();
public static PackageManagerViewModel PackageManagerViewModel =>
Services.GetRequiredService<PackageManagerViewModel>();
public static InferenceSettingsViewModel InferenceSettingsViewModel =>
Services.GetRequiredService<InferenceSettingsViewModel>();
public static MainSettingsViewModel MainSettingsViewModel
{
get
{
var vm = Services.GetRequiredService<MainSettingsViewModel>();
vm.AllBaseModelTypes = new List<string>()
{
CivitBaseModelType.WanVideo.GetStringValue(),
CivitBaseModelType.Sdxl10.GetStringValue(),
CivitBaseModelType.Flux1D.GetStringValue(),
"Flux 1. Kontext",
}
.Select(s => new BaseModelOptionViewModel { ModelType = s, IsSelected = true })
.ToList();
return vm;
}
}
public static AccountSettingsViewModel AccountSettingsViewModel =>
Services.GetRequiredService<AccountSettingsViewModel>();
public static NotificationSettingsViewModel NotificationSettingsViewModel =>
Services.GetRequiredService<NotificationSettingsViewModel>();
public static UpdateSettingsViewModel UpdateSettingsViewModel
{
get
{
var vm = Services.GetRequiredService<UpdateSettingsViewModel>();
var update = new UpdateInfo
{
Version = SemVersion.Parse("2.0.1"),
ReleaseDate = DateTimeOffset.Now,
Url = new Uri("https://example.org"),
Changelog = new Uri("https://example.org"),
HashBlake3 = "",
Signature = "",
};
vm.UpdateStatus = new UpdateStatusChangedEventArgs
{
LatestUpdate = update,
UpdateChannels = new Dictionary<UpdateChannel, UpdateInfo>
{
[UpdateChannel.Stable] = update,
[UpdateChannel.Preview] = update,
[UpdateChannel.Development] = update,
},
CheckedAt = DateTimeOffset.UtcNow,
};
return vm;
}
}
public static CivitAiBrowserViewModel CivitAiBrowserViewModel =>
Services.GetRequiredService<CivitAiBrowserViewModel>();
public static CheckpointBrowserViewModel CheckpointBrowserViewModel =>
Services.GetRequiredService<CheckpointBrowserViewModel>();
public static CivitDetailsPageViewModel CivitDetailsPageViewModel =>
DialogFactory.Get<CivitDetailsPageViewModel>(vm =>
{
vm.CivitModel = new CivitModel
{
Name = "BB95 Furry Mix",
Description = "A furry mix of BB95",
Stats = new CivitModelStats
{
Rating = 3.5,
RatingCount = 24,
ThumbsUpCount = 1337,
DownloadCount = 100_000,
},
Tags = ["base model", "furry", "animals", "photorealistic", "highly detailed", "yiff"],
ModelVersions =
[
new CivitModelVersion
{
Name = "v1.2.2-Inpainting",
PublishedAt = DateTimeOffset.Now,
Images =
[
new CivitImage
{
Url =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/244bc929-9bbc-44b2-8a26-7622a1669f4a/original=true,quality=90/00123-3430906941-1girl,%20hatsune%20miku,%20white%20pupils,%20power%20elements,%20microphone,%20vibrant%20blue%20color%20palette,%20abstract,abstract%20background,%20dreamli.jpeg",
},
new CivitImage
{
Url =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/aa671302-496f-4dcc-839a-b75a70a7665e/original=true,quality=90/00136-4204868169-1girl,%20solo,%20long%20hair,%20city,%20boots,%20hands%20in%20pockets,%20coat,%20blonde%20hair,%20sky,%20planet,%20night,%20knee%20boots,%20building,%20star%20_(sky_).jpeg",
},
],
Files =
[
new CivitFile
{
Name = "bb95-v100-uwu-reallylongfilename-v1234576802.safetensors",
Type = CivitFileType.Model,
Metadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = "fp16",
Size = "pruned",
},
},
new CivitFile
{
Name = "bb95-v100-uwu-reallylongfilename-v1234576802-fp32.safetensors",
Type = CivitFileType.Model,
Metadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = "fp32",
Size = "full",
},
Hashes = new CivitFileHashes
{
BLAKE3 =
"A7383E54F2E4570678B0F18545B2EB8FD95325DA76CCBA8467DBDBD481CF6B99",
SHA256 =
"BDB59BAC77D94AE7A55FF893170F9554C3F349E48A1B73C0C17C0B7C6F4D41A2",
},
},
],
},
new CivitModelVersion { Name = "v1.2.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v1.1.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v1.0.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.9.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.8.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.7.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.6.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.5.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
new CivitModelVersion { Name = "v0.4.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
],
Creator = new CivitCreator
{
Image = "https://gravatar.com/avatar/fe74084ae8a081dc2283f5bde4736756ad?f=y&d=retro",
Username = "creator-1",
},
};
});
public static SelectModelVersionViewModel SelectModelVersionViewModel =>
DialogFactory.Get<SelectModelVersionViewModel>(vm =>
{
// Sample data
var sampleCivitVersions = new List<CivitModelVersion>
{
new()
{
Name = "BB95 Furry Mix",
Description =
@"Introducing SnoutMix
A Mix of non-Furry and Furry models such as Furtastic and BB95Furry to create a great variety of anthro AI generation options, but bringing out more detail, still giving a lot of freedom to customise the human aspects, and having great backgrounds, with a focus on something more realistic. Works well with realistic character loras.
The gallery images are often inpainted, but you will get something very similar if copying their data directly. They are inpainted using the same model, therefore all results are possible without anything custom/hidden-away. Controlnet Tiled is applied to enhance them further afterwards. Gallery images were made with same model but before it was renamed",
BaseModel = "SD 1.5",
Files = new List<CivitFile>
{
new()
{
Name = "bb95-v100-uwu-reallylongfilename-v1234576802.safetensors",
Type = CivitFileType.Model,
Metadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = "fp16",
Size = "pruned",
},
},
new()
{
Name = "bb95-v100-uwu-reallylongfilename-v1234576802-fp32.safetensors",
Type = CivitFileType.Model,
Metadata = new CivitFileMetadata
{
Format = CivitModelFormat.SafeTensor,
Fp = "fp32",
Size = "full",
},
Hashes = new CivitFileHashes { BLAKE3 = "ABCD" },
},
},
},
};
var sampleViewModel = new ModelVersionViewModel(
Services.GetRequiredService<IModelIndexService>(),
sampleCivitVersions[0]
);
// Sample data for dialogs
vm.Versions = new List<ModelVersionViewModel> { sampleViewModel };
vm.Title = sampleCivitVersions[0].Name;
vm.Description = sampleCivitVersions[0].Description;
vm.SelectedVersionViewModel = sampleViewModel;
});
public static OneClickInstallViewModel OneClickInstallViewModel =>
Services.GetRequiredService<OneClickInstallViewModel>();
public static InferenceViewModel InferenceViewModel => Services.GetRequiredService<InferenceViewModel>();
public static SelectDataDirectoryViewModel SelectDataDirectoryViewModel =>
Services.GetRequiredService<SelectDataDirectoryViewModel>();
public static ProgressManagerViewModel ProgressManagerViewModel =>
Services.GetRequiredService<ProgressManagerViewModel>();
public static ExceptionViewModel ExceptionViewModel =>
DialogFactory.Get<ExceptionViewModel>(viewModel =>
{
// Use try-catch to generate traceback information
try
{
try
{
throw new OperationCanceledException("Example");
}
catch (OperationCanceledException e)
{
throw new AggregateException(e);
}
}
catch (AggregateException e)
{
viewModel.Exception = e;
}
});
public static EnvVarsViewModel EnvVarsViewModel =>
DialogFactory.Get<EnvVarsViewModel>(viewModel =>
{
viewModel.EnvVars = new ObservableCollection<EnvVarKeyPair> { new("UWU", "TRUE") };
});
public static PythonPackagesViewModel PythonPackagesViewModel =>
DialogFactory.Get<PythonPackagesViewModel>(vm =>
{
vm.AddPackages(new PipPackageInfo("pip", "1.0.0"), new PipPackageInfo("torch", "2.1.0+cu121"));
});
public static LykosLoginViewModel LykosLoginViewModel => DialogFactory.Get<LykosLoginViewModel>();
public static OAuthConnectViewModel OAuthConnectViewModel =>
DialogFactory.Get<OAuthConnectViewModel>(vm =>
{
vm.Url =
"https://www.example.org/oauth2/authorize?"
+ "client_id=66ad566552679cb6e650be01ed6f8d2ae9a0f803c0369850a5c9ee82a2396062&"
+ "scope=identity%20identity.memberships&"
+ "response_type=code&state=test%40example.org&"
+ "redirect_uri=http://localhost:5022/api/oauth/patreon/callback";
});
public static OAuthLoginViewModel OAuthLoginViewModel =>
DialogFactory.Get<OAuthLoginViewModel>(vm =>
{
vm.Url =
"https://www.example.org/oauth2/authorize?"
+ "client_id=66ad566552679cb6e650be01ed6f8d2ae9a0f803c0369850a5c9ee82a2396062&"
+ "scope=identity%20identity.memberships&"
+ "response_type=code&state=test%40example.org&"
+ "redirect_uri=http://localhost:5022/api/oauth/patreon/callback";
});
public static OAuthDeviceAuthViewModel OAuthDeviceAuthViewModel =>
DialogFactory.Get<OAuthDeviceAuthViewModel>(vm =>
{
vm.VerificationUri = new Uri("https://example.org/connect/verify");
vm.UserCode = "AB23-CD56";
});
public static PythonPackageSpecifiersViewModel PythonPackageSpecifiersViewModel =>
DialogFactory.Get<PythonPackageSpecifiersViewModel>();
public static MaskEditorViewModel MaskEditorViewModel => DialogFactory.Get<MaskEditorViewModel>();
public static InferenceTextToImageViewModel InferenceTextToImageViewModel =>
DialogFactory.Get<InferenceTextToImageViewModel>(vm =>
{
vm.OutputProgress.Value = 10;
vm.OutputProgress.Maximum = 30;
vm.OutputProgress.Text = "Sampler 10/30";
});
public static InferenceImageToVideoViewModel InferenceImageToVideoViewModel =>
DialogFactory.Get<InferenceImageToVideoViewModel>(vm =>
{
vm.OutputProgress.Value = 10;
vm.OutputProgress.Maximum = 30;
vm.OutputProgress.Text = "Sampler 10/30";
});
public static InferenceImageToImageViewModel InferenceImageToImageViewModel =>
DialogFactory.Get<InferenceImageToImageViewModel>();