|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- # NativeLibraryConfig
-
- 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!
-
- ```csharp
- public sealed class NativeLibraryConfig
- ```
-
- Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)
-
- ## Properties
-
- ### **Instance**
-
- Get the config instance
-
- ```csharp
- public static NativeLibraryConfig Instance { get; }
- ```
-
- #### Property Value
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- ### **LibraryHasLoaded**
-
- Check if the native library has already been loaded. Configuration cannot be modified if this is true.
-
- ```csharp
- public static bool LibraryHasLoaded { get; internal set; }
- ```
-
- #### Property Value
-
- [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
-
- ## Methods
-
- ### **WithLibrary(String, String)**
-
- Load a specified native library as backend for LLamaSharp.
- When this method is called, all the other configurations will be ignored.
-
- ```csharp
- public NativeLibraryConfig WithLibrary(string llamaPath, string llavaPath)
- ```
-
- #### Parameters
-
- `llamaPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
- The full path to the llama library to load.
-
- `llavaPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
- The full path to the llava library to load.
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithCuda(Boolean)**
-
- Configure whether to use cuda backend if possible.
-
- ```csharp
- public NativeLibraryConfig WithCuda(bool enable)
- ```
-
- #### Parameters
-
- `enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithAvx(AvxLevel)**
-
- Configure the prefferred avx support level of the backend.
-
- ```csharp
- public NativeLibraryConfig WithAvx(AvxLevel level)
- ```
-
- #### Parameters
-
- `level` [AvxLevel](./llama.native.nativelibraryconfig.avxlevel.md)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithAutoFallback(Boolean)**
-
- Configure whether to allow fallback when there's no match for preferred settings.
-
- ```csharp
- public NativeLibraryConfig WithAutoFallback(bool enable)
- ```
-
- #### Parameters
-
- `enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **SkipCheck(Boolean)**
-
- 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.
-
- ```csharp
- public NativeLibraryConfig SkipCheck(bool enable)
- ```
-
- #### Parameters
-
- `enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithLogs(Boolean)**
-
- Whether to output the logs to console when loading the native library with your configuration.
-
- ```csharp
- public NativeLibraryConfig WithLogs(bool enable)
- ```
-
- #### Parameters
-
- `enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithLogs(LLamaLogLevel)**
-
- Enable console logging with the specified log logLevel.
-
- ```csharp
- public NativeLibraryConfig WithLogs(LLamaLogLevel logLevel)
- ```
-
- #### Parameters
-
- `logLevel` [LLamaLogLevel](./llama.native.llamaloglevel.md)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- #### Exceptions
-
- [InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)<br>
- Thrown if `LibraryHasLoaded` is true.
-
- ### **WithSearchDirectories(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.
-
- ```csharp
- public NativeLibraryConfig WithSearchDirectories(IEnumerable<string> directories)
- ```
-
- #### Parameters
-
- `directories` [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- ### **WithSearchDirectory(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.
-
- ```csharp
- public NativeLibraryConfig WithSearchDirectory(string directory)
- ```
-
- #### Parameters
-
- `directory` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
-
- #### Returns
-
- [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)<br>
-
- ### **CheckAndGatherDescription(LibraryName)**
-
- ```csharp
- internal static Description CheckAndGatherDescription(LibraryName library)
- ```
-
- #### Parameters
-
- `library` [LibraryName](./llama.native.libraryname.md)<br>
-
- #### Returns
-
- [Description](./llama.native.nativelibraryconfig.description.md)<br>
-
- ### **AvxLevelToString(AvxLevel)**
-
- ```csharp
- internal static string AvxLevelToString(AvxLevel level)
- ```
-
- #### Parameters
-
- `level` [AvxLevel](./llama.native.nativelibraryconfig.avxlevel.md)<br>
-
- #### Returns
-
- [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
|