Skip to content

Commit

Permalink
improved model download support
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarrere committed Dec 21, 2024
1 parent 19d3049 commit c3ad67c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
7 changes: 6 additions & 1 deletion LM-Kit-Maestro/Services/LLMFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using LMKit.Model;
using LMKit.Maestro.UI;

namespace LMKit.Maestro.Services;

Expand Down Expand Up @@ -190,7 +191,11 @@ public void DeleteModel(ModelCard modelCard)
{
if (modelCard.IsLocallyAvailable)
{
File.Delete(modelCard.ModelUri.LocalPath);
File.Delete(modelCard.LocalPath);

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 194 in LM-Kit-Maestro/Services/LLMFileManager.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'LocalPath' and no accessible extension method 'LocalPath' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)
}
else
{
throw new Exception(TooltipLabels.ModelFileNotAvailableLocally);
}
}

Expand Down
4 changes: 2 additions & 2 deletions LM-Kit-Maestro/UI/Pages/ModelsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@
<Label.FormattedText>
<FormattedString>
<Span Text="You have "/>
<Span Text="{Binding ModelListViewModel.UserModels.Count}" FontAttributes="Bold"/>
<Span Text=" installed model(s) taking a total of "/>
<Span Text="{Binding ModelListViewModel.DownloadedCount}" FontAttributes="Bold"/>
<Span Text=" downloaded model(s) taking a total of "/>
<Span Text="{Binding ModelListViewModel.TotalModelSize, Converter={converters:FileSizeConverter}}" FontAttributes="Bold"/>
</FormattedString>
</Label.FormattedText>
Expand Down
1 change: 1 addition & 0 deletions LM-Kit-Maestro/UI/TooltipLabels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ internal static class TooltipLabels
public const string ContextSize = "Context size";
public const string SamplingConfiguration = "Sampling configuration";
public const string SamplingMode = "Sampling mode";
public const string ModelFileNotAvailableLocally = "The model file is not available locally";
}
}
18 changes: 18 additions & 0 deletions LM-Kit-Maestro/ViewModels/ModelListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ public partial class ModelListViewModel : ViewModelBase

private ObservableCollection<ModelInfoViewModel> _userModels = new ObservableCollection<ModelInfoViewModel>();

public int DownloadedCount
{
get
{
int count = 0;

foreach (var model in _userModels)
{
if (model.ModelInfo.IsLocallyAvailable)
{
count++;
}
}

return count;
}
}

[ObservableProperty]
long _totalModelSize;

Expand Down
2 changes: 1 addition & 1 deletion LM-Kit-Maestro/ViewModels/Pages/ModelsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void DeleteModel(ModelInfoViewModel modelCardViewModel)
catch (Exception ex)
{
_popupService.DisplayAlert("Failure to delete model file",
$"The model file could not be deleted:\n {ex.Message}", "OK");
$"{ex.Message}", "OK");
}
}

Expand Down

0 comments on commit c3ad67c

Please sign in to comment.