Skip to content

Commit

Permalink
Filter Embedding models (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarrere authored Nov 22, 2024
1 parent 79e4e6a commit 8375acf
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions LM-Kit-Maestro/Services/LLMFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using System.ComponentModel;
using LMKit.Model;

namespace LMKitMaestro.Services;

Expand Down Expand Up @@ -79,13 +80,13 @@ public void Initialize()
ModelsFolderPath = _appSettingsService.ModelsFolderPath;

#if WINDOWS
_fileSystemWatcher.Changed += OnFileChanged;
_fileSystemWatcher.Deleted += OnFileDeleted;
_fileSystemWatcher.Renamed += OnFileRenamed;
_fileSystemWatcher.Created += OnFileCreated;
_fileSystemWatcher.Changed += OnFileChanged;
_fileSystemWatcher.Deleted += OnFileDeleted;
_fileSystemWatcher.Renamed += OnFileRenamed;
_fileSystemWatcher.Created += OnFileCreated;

_fileSystemWatcher.IncludeSubdirectories = true;
_fileSystemWatcher.EnableRaisingEvents = true;
_fileSystemWatcher.IncludeSubdirectories = true;
_fileSystemWatcher.EnableRaisingEvents = true;
#endif
}

Expand Down Expand Up @@ -483,14 +484,24 @@ private void OnFileRecordPathChanged(object? sender, EventArgs e)
UserModels[index] = new ModelInfo(publisher, repository, fileName, fileRecordPathChangedEventArgs.NewPath, UserModels[index].FileSize);
}
}
#endregion
#endregion

#region Static methods

private static bool IsTextCompletionModel(string filePath)
{
using (var model = new LLM(filePath, loadingOptions: new LLM.LoadingOptions() { LoadTensors = false }))
{
return !model.IsEmbeddingModel;
}
}

private static bool TryValidateModelFile(string filePath, string modelFolderPath, out ModelInfo? modelInfo)
{
if (LMKit.Model.LLM.ValidateFormat(filePath))
if (LLM.ValidateFormat(filePath) &&
IsTextCompletionModel(filePath))
{

if (FileHelpers.GetModelInfoFromPath(filePath, modelFolderPath,
out string publisher, out string repository, out string fileName))
{
Expand Down

0 comments on commit 8375acf

Please sign in to comment.