diff --git a/LLama/Native/NativeApi.Load.cs b/LLama/Native/NativeApi.Load.cs
index 36ae55bf..d8a88725 100644
--- a/LLama/Native/NativeApi.Load.cs
+++ b/LLama/Native/NativeApi.Load.cs
@@ -275,7 +275,7 @@ namespace LLama.Native
var libraryTryLoadOrder = GetLibraryTryOrder(configuration);
- string[] preferredPaths = configuration.SearchDirectories.OrderByDescending(kv => kv.Value).Select(kv => kv.Key).ToArray();
+ string[] preferredPaths = configuration.SearchDirectories;
string[] possiblePathPrefix = new string[] {
System.AppDomain.CurrentDomain.BaseDirectory,
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ?? ""
diff --git a/LLama/Native/NativeLibraryConfig.cs b/LLama/Native/NativeLibraryConfig.cs
index fcef9c34..e5135970 100644
--- a/LLama/Native/NativeLibraryConfig.cs
+++ b/LLama/Native/NativeLibraryConfig.cs
@@ -32,10 +32,7 @@ namespace LLama.Native
///
/// search directory -> priority level, 0 is the lowest.
///
- private Dictionary _searchDirectories = new Dictionary()
- {
- { "./", 0 }
- };
+ private List _searchDirectories = new List();
private static void ThrowIfLoaded()
{
@@ -134,20 +131,13 @@ namespace LLama.Native
/// directories must be the same as the default directory. Besides, the directory
/// won't be used recursively.
///
- /// The directories and corresponding priorities, in which 0 is the lowest. The default path has priority 0.
+ ///
///
- public NativeLibraryConfig WithSearchDirectories(IDictionary directoriesAndPriorities)
+ public NativeLibraryConfig WithSearchDirectories(IEnumerable directories)
{
ThrowIfLoaded();
- foreach(var (directory, priority) in directoriesAndPriorities)
- {
- if(priority < 0)
- {
- throw new ArgumentException("Priority must be a positive number.");
- }
- _searchDirectories[directory] = priority;
- }
+ _searchDirectories.AddRange(directories);
return this;
}
@@ -157,17 +147,12 @@ namespace LLama.Native
/// won't be used recursively.
///
///
- /// The priority of your added search path. 0 is the lowest. The default path has priority 0.
///
- public NativeLibraryConfig WithSearchDirectory(string directory, int priority)
+ public NativeLibraryConfig WithSearchDirectory(string directory)
{
ThrowIfLoaded();
- if (priority < 0)
- {
- throw new ArgumentException("Priority must be a positive number.");
- }
- _searchDirectories[directory] = priority;
+ _searchDirectories.Add(directory);
return this;
}
@@ -184,7 +169,7 @@ namespace LLama.Native
Instance._allowFallback,
Instance._skipCheck,
Instance._logging,
- Instance._searchDirectories);
+ Instance._searchDirectories.Concat(new string[] { "./" }).ToArray());
}
internal static string AvxLevelToString(AvxLevel level)
@@ -241,7 +226,7 @@ namespace LLama.Native
Avx512,
}
- internal record Description(string Path, bool UseCuda, AvxLevel AvxLevel, bool AllowFallback, bool SkipCheck, bool Logging, Dictionary SearchDirectories)
+ internal record Description(string Path, bool UseCuda, AvxLevel AvxLevel, bool AllowFallback, bool SkipCheck, bool Logging, string[] SearchDirectories)
{
public override string ToString()
{
@@ -254,7 +239,7 @@ namespace LLama.Native
_ => "Unknown"
};
- string searchDirectoriesString = string.Join(", ", SearchDirectories.Select(kv => $"[{kv.Key}: {kv.Value}]"));
+ string searchDirectoriesString = "{ " + string.Join(", ", SearchDirectories) + " }";
return $"NativeLibraryConfig Description:\n" +
$"- Path: {Path}\n" +