-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
522 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
using LMKit.Maestro.Services; | ||
using LMKit.Maestro.ViewModels; | ||
using LMKit.Model; | ||
|
||
namespace LMKit.Maestro.Helpers | ||
{ | ||
internal static class MaestroHelpers | ||
{ | ||
public static ModelInfoViewModel? TryGetExistingModelInfoViewModel(ICollection<ModelInfoViewModel> modelInfoViewModels, ModelInfo modelInfo) | ||
public static ModelInfoViewModel? TryGetExistingModelInfoViewModel(ICollection<ModelInfoViewModel> modelCardViewModels, ModelCard modelCard) | ||
{ | ||
foreach (var modelInfoViewModel in modelInfoViewModels) | ||
{ | ||
if (string.CompareOrdinal(modelInfoViewModel.ModelInfo.FileName, modelInfo.FileName) == 0 && | ||
string.CompareOrdinal(modelInfoViewModel.ModelInfo.Repository, modelInfo.Repository) == 0 && | ||
string.CompareOrdinal(modelInfoViewModel.ModelInfo.Publisher, modelInfo.Publisher) == 0) | ||
foreach (var modelCardViewModel in modelCardViewModels) | ||
{//todo: use sha instead | ||
if (string.CompareOrdinal(modelCardViewModel.ModelInfo.FileName, modelCard.FileName) == 0 && | ||
string.CompareOrdinal(modelCardViewModel.ModelInfo.Repository, modelCard.Repository) == 0 && | ||
string.CompareOrdinal(modelCardViewModel.ModelInfo.Publisher, modelCard.Publisher) == 0) | ||
{ | ||
return modelInfoViewModel; | ||
return modelCardViewModel; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static ModelInfoViewModel? TryGetExistingModelInfoViewModel(string modelsFolderPath, ICollection<ModelInfoViewModel> modelInfoViewModels, Uri modelFileUri) | ||
public static ModelInfoViewModel? TryGetExistingModelInfoViewModel(string modelsFolderPath, ICollection<ModelInfoViewModel> modelCardViewModels, Uri modelFileUri) | ||
{ | ||
if (FileHelpers.GetModelInfoFromPath(modelFileUri.LocalPath, modelsFolderPath, out string publisher, out string repository, out string fileName)) | ||
{ | ||
foreach (var modelInfoViewModel in modelInfoViewModels) | ||
foreach (var modelCardViewModel in modelCardViewModels) | ||
{ | ||
if (string.CompareOrdinal(modelInfoViewModel.ModelInfo.FileName, fileName) == 0 && | ||
string.CompareOrdinal(modelInfoViewModel.ModelInfo.Repository, repository) == 0 && | ||
string.CompareOrdinal(modelInfoViewModel.ModelInfo.Publisher, publisher) == 0) | ||
if (string.CompareOrdinal(modelCardViewModel.ModelInfo.FileName, fileName) == 0 && | ||
string.CompareOrdinal(modelCardViewModel.ModelInfo.Repository, repository) == 0 && | ||
string.CompareOrdinal(modelCardViewModel.ModelInfo.Publisher, publisher) == 0) | ||
{ | ||
return modelInfoViewModel; | ||
return modelCardViewModel; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
//handling unsorted models. | ||
foreach (var modelInfoViewModel in modelInfoViewModels) | ||
foreach (var modelCardViewModel in modelCardViewModels) | ||
{ | ||
if (modelInfoViewModel.ModelInfo.FileUri == modelFileUri) | ||
if (modelCardViewModel.ModelInfo.ModelUri == modelFileUri) | ||
{ | ||
return modelInfoViewModel; | ||
return modelCardViewModel; | ||
} | ||
} | ||
} | ||
|
||
//Loïc: we have an architecture defect. We can reach this stage, especially at startup, while modelInfoViewModels is not completely loaded. | ||
//Loïc: we have an architecture defect. We can reach this stage, especially at startup, while modelCardViewModels is not completely loaded. | ||
//todo Evan: fix. | ||
return new ModelInfoViewModel(new ModelInfo(publisher, repository, fileName, modelFileUri)); | ||
return new ModelInfoViewModel(new ModelCard(modelFileUri)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
using System.Collections.ObjectModel; | ||
using LMKit.Model; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace LMKit.Maestro.Services; | ||
|
||
public interface ILLMFileManager | ||
{ | ||
ObservableCollection<ModelInfo> UserModels { get; } | ||
ObservableCollection<ModelCard> UserModels { get; } | ||
ObservableCollection<Uri> UnsortedModels { get; } | ||
bool FileCollectingInProgress { get; } | ||
string ModelsFolderPath { get; set; } | ||
string ModelStorageDirectory { get; set; } | ||
event EventHandler? FileCollectingCompleted; | ||
void Initialize(); | ||
void DeleteModel(ModelInfo modelInfo); | ||
void DeleteModel(ModelCard modelCard); | ||
} |
Oops, something went wrong.