Namespace: LLama.Native
Allows configuration of the native llama.cpp libraries to load and use.
All configuration must be done before using any other LLamaSharp methods!
public sealed class NativeLibraryConfig
Inheritance Object → NativeLibraryConfig
Get the config instance
public static NativeLibraryConfig Instance { get; }
Check if the native library has already been loaded. Configuration cannot be modified if this is true.
public static bool LibraryHasLoaded { get; internal set; }
Load a specified native library as backend for LLamaSharp.
When this method is called, all the other configurations will be ignored.
public NativeLibraryConfig WithLibrary(string llamaPath, string llavaPath)
llamaPath String
The full path to the llama library to load.
llavaPath String
The full path to the llava library to load.
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Configure whether to use cuda backend if possible.
public NativeLibraryConfig WithCuda(bool enable)
enable Boolean
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Configure the prefferred avx support level of the backend.
public NativeLibraryConfig WithAvx(AvxLevel level)
level AvxLevel
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Configure whether to allow fallback when there's no match for preferred settings.
public NativeLibraryConfig WithAutoFallback(bool enable)
enable Boolean
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Whether to skip the check when you don't allow fallback. This option
may be useful under some complex conditions. For example, you're sure
you have your cublas configured but LLamaSharp take it as invalid by mistake.
public NativeLibraryConfig SkipCheck(bool enable)
enable Boolean
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Whether to output the logs to console when loading the native library with your configuration.
public NativeLibraryConfig WithLogs(bool enable)
enable Boolean
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Enable console logging with the specified log logLevel.
public NativeLibraryConfig WithLogs(LLamaLogLevel logLevel)
logLevel LLamaLogLevel
InvalidOperationException
Thrown if LibraryHasLoaded is true.
Add self-defined search directories. Note that the file stucture of the added
directories must be the same as the default directory. Besides, the directory
won't be used recursively.
public NativeLibraryConfig WithSearchDirectories(IEnumerable<string> directories)
directories IEnumerable<String>
Add self-defined search directories. Note that the file stucture of the added
directories must be the same as the default directory. Besides, the directory
won't be used recursively.
public NativeLibraryConfig WithSearchDirectory(string directory)
directory String
internal static Description CheckAndGatherDescription(LibraryName library)
library LibraryName
internal static string AvxLevelToString(AvxLevel level)
level AvxLevel