You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
using System.IO; |
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
using CommunityToolkit.Mvvm.Input; |
|
using StabilityMatrix.Avalonia.Models.HuggingFace; |
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
using StabilityMatrix.Core.Extensions; |
|
using StabilityMatrix.Core.Models; |
|
|
|
namespace StabilityMatrix.Avalonia.ViewModels.HuggingFacePage; |
|
|
|
public partial class HuggingfaceItemViewModel : ViewModelBase |
|
{ |
|
[ObservableProperty] |
|
private HuggingfaceItem item; |
|
|
|
[ObservableProperty] |
|
private bool isSelected; |
|
|
|
public string LicenseUrl => |
|
$"https://huggingface.co/{Item.RepositoryPath}/blob/main/{Item.LicensePath ?? "README.md"}"; |
|
public string RepoUrl => $"https://huggingface.co/{Item.RepositoryPath}"; |
|
|
|
public required string? ModelsDir { get; init; } |
|
|
|
public bool Exists => |
|
File.Exists( |
|
Path.Combine( |
|
ModelsDir, |
|
Item.ModelCategory.ConvertTo<SharedFolderType>().ToString(), |
|
Item.Subfolder ?? string.Empty, |
|
Item.Files[0] |
|
) |
|
); |
|
|
|
[RelayCommand] |
|
private void ToggleSelected() |
|
{ |
|
IsSelected = !IsSelected; |
|
} |
|
}
|
|
|