Skip to content

Commit

Permalink
Models sorting improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarrere committed Dec 25, 2024
1 parent 7356722 commit 52cb92d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions LM-Kit-Maestro/Services/LLMFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ private void CollectModels()
foreach (var filePath in files)
{
bool processed = false;

foreach (var predefinedModel in _predefinedModelCards)
{
if (predefinedModel.LocalPath == filePath)
Expand Down
2 changes: 1 addition & 1 deletion LM-Kit-Maestro/UI/Pages/ModelsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@

<Label VerticalOptions="Center"
Grid.Column="2"
Text="{Binding ModelInfo.ModelName}"
Text="{Binding ModelInfo.ShortModelName}"
ToolTipProperties.Text="{Binding ModelInfo.Description}"/>


Expand Down
4 changes: 4 additions & 0 deletions LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public bool IsLocallyAvailable
[ObservableProperty]
string _name;

[ObservableProperty]
string _shortName;

[ObservableProperty]
string _modelPath;

Expand Down Expand Up @@ -73,6 +76,7 @@ public ModelInfoViewModel(ModelCard modelCard)
{
_modelCard = modelCard;
Name = modelCard.ModelName;
ShortName = modelCard.ShortModelName;

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

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

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

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

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

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

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

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

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

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

Check failure on line 79 in LM-Kit-Maestro/ViewModels/ModelInfoViewModel.cs

View workflow job for this annotation

GitHub Actions / build

'ModelCard' does not contain a definition for 'ShortModelName' and no accessible extension method 'ShortModelName' accepting a first argument of type 'ModelCard' could be found (are you missing a using directive or an assembly reference?)
FileSize = modelCard.FileSize;
Precision = modelCard.QuantizationPrecision.ToString() + (modelCard.QuantizationPrecision > 1 ? "-bits" : "-bit");
ModelSize = Math.Round((double)modelCard.ParameterCount / 1000000000, 1).ToString().Replace(",", ".") + "B";
Expand Down
11 changes: 10 additions & 1 deletion LM-Kit-Maestro/ViewModels/ModelListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ private void AddModel(ModelInfoViewModel modelCardViewModel, bool sort = true)
{
int insertIndex = 0;

while (insertIndex < Models.Count && string.Compare(Models[insertIndex].Name, modelCardViewModel.Name) < 0)
//First sorting pass: Sort by short name in ascending order.
while (insertIndex < Models.Count && string.Compare(Models[insertIndex].ShortName, modelCardViewModel.ShortName) < 0)
{
insertIndex++;
}

//Second sorting pass: by model size
while (insertIndex < Models.Count &&
string.Compare(Models[insertIndex].ShortName, modelCardViewModel.ShortName) == 0 &&
Models[insertIndex].FileSize < modelCardViewModel.FileSize)
{
insertIndex++;
}
Expand Down

0 comments on commit 52cb92d

Please sign in to comment.