- Deleted `NativeInfo` (internal class, not used anywhere)tags/v0.5.1
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,5 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System.Text; | |||||
| namespace LLama.Examples.NewVersion | namespace LLama.Examples.NewVersion | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using LLama; | |||||
| using LLama.Common; | |||||
| using LLama.Examples; | |||||
| using LLama.Examples.NewVersion; | |||||
| using LLama.Examples.NewVersion; | |||||
| using LLama.Examples.Old; | using LLama.Examples.Old; | ||||
| Console.WriteLine("======================================================================================================"); | Console.WriteLine("======================================================================================================"); | ||||
| @@ -1,4 +1,3 @@ | |||||
| using System.Text; | |||||
| using LLama.Common; | using LLama.Common; | ||||
| namespace LLama.Unittest | namespace LLama.Unittest | ||||
| @@ -1,5 +1,4 @@ | |||||
| using System.Text; | |||||
| using LLama.Common; | |||||
| using LLama.Common; | |||||
| using LLama.Native; | using LLama.Native; | ||||
| namespace LLama.Unittest | namespace LLama.Unittest | ||||
| @@ -1,5 +1,4 @@ | |||||
| using System.Text; | |||||
| using LLama.Common; | |||||
| using LLama.Common; | |||||
| namespace LLama.Unittest | namespace LLama.Unittest | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace LLama.Abstractions | namespace LLama.Abstractions | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using LLama.Common; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using System.Collections.Generic; | |||||
| using System.Threading; | using System.Threading; | ||||
| namespace LLama.Abstractions | namespace LLama.Abstractions | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using System.Collections.Generic; | |||||
| namespace LLama.Abstractions | namespace LLama.Abstractions | ||||
| { | { | ||||
| @@ -15,6 +13,7 @@ namespace LLama.Abstractions | |||||
| /// <param name="tokens"></param> | /// <param name="tokens"></param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| IEnumerable<string> Transform(IEnumerable<string> tokens); | IEnumerable<string> Transform(IEnumerable<string> tokens); | ||||
| /// <summary> | /// <summary> | ||||
| /// Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously. | /// Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace LLama.Abstractions | |||||
| namespace LLama.Abstractions | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// An interface for text transformations. | /// An interface for text transformations. | ||||
| @@ -1,6 +1,5 @@ | |||||
| using LLama.Abstractions; | using LLama.Abstractions; | ||||
| using System; | using System; | ||||
| using System.Text; | |||||
| namespace LLama.Common | namespace LLama.Common | ||||
| { | { | ||||
| @@ -266,10 +266,7 @@ namespace LLama | |||||
| public virtual IEnumerable<string> Infer(string text, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = default) | public virtual IEnumerable<string> Infer(string text, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = default) | ||||
| { | { | ||||
| cancellationToken.ThrowIfCancellationRequested(); | cancellationToken.ThrowIfCancellationRequested(); | ||||
| if (inferenceParams is null) | |||||
| { | |||||
| inferenceParams = new InferenceParams(); | |||||
| } | |||||
| inferenceParams ??= new InferenceParams(); | |||||
| InferStateArgs args = new InferStateArgs() | InferStateArgs args = new InferStateArgs() | ||||
| { | { | ||||
| @@ -108,10 +108,7 @@ namespace LLama | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| protected override void PreprocessInputs(string text, InferStateArgs args) | protected override void PreprocessInputs(string text, InferStateArgs args) | ||||
| { | { | ||||
| if(args.Antiprompts is null) | |||||
| { | |||||
| args.Antiprompts = new List<string>(); | |||||
| } | |||||
| args.Antiprompts ??= new List<string>(); | |||||
| args.Antiprompts.Add(_instructionPrefix); | args.Antiprompts.Add(_instructionPrefix); | ||||
| if (_is_prompt_run) | if (_is_prompt_run) | ||||
| { | { | ||||
| @@ -160,7 +157,7 @@ namespace LLama | |||||
| if (_pastTokensCount > 0 && args.WaitForInput) | if (_pastTokensCount > 0 && args.WaitForInput) | ||||
| { | { | ||||
| extraOutputs = new string[] { "\n> " }; | |||||
| extraOutputs = new[] { "\n> " }; | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -154,7 +154,7 @@ namespace LLama | |||||
| if (_embeds.Count > 0 && _embeds.Last() == NativeApi.llama_token_eos()) | if (_embeds.Count > 0 && _embeds.Last() == NativeApi.llama_token_eos()) | ||||
| { | { | ||||
| extraOutputs = new string[] { " [end of text]\n" }; | |||||
| extraOutputs = new[] { " [end of text]\n" }; | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -1,11 +1,10 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | |||||
| namespace LLama.Native | namespace LLama.Native | ||||
| { | { | ||||
| public delegate void LlamaProgressCallback(float progress, IntPtr ctx); | public delegate void LlamaProgressCallback(float progress, IntPtr ctx); | ||||
| [StructLayout(LayoutKind.Sequential)] | [StructLayout(LayoutKind.Sequential)] | ||||
| public struct LLamaContextParams | public struct LLamaContextParams | ||||
| { | { | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System.Runtime.InteropServices; | |||||
| namespace LLama.Native | |||||
| namespace LLama.Native | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Quantizer parameters used in the native API | /// Quantizer parameters used in the native API | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| using System.Runtime.InteropServices; | |||||
| namespace LLama.Native | namespace LLama.Native | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| using System.Runtime.InteropServices; | |||||
| namespace LLama.Native | namespace LLama.Native | ||||
| { | { | ||||
| @@ -16,6 +13,6 @@ namespace LLama.Native | |||||
| /// <remarks>not great API - very likely to change</remarks> | /// <remarks>not great API - very likely to change</remarks> | ||||
| /// <returns>Returns 0 on success</returns> | /// <returns>Returns 0 on success</returns> | ||||
| [DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)] | [DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)] | ||||
| public unsafe static extern int llama_model_quantize(string fname_inp, string fname_out, LLamaModelQuantizeParams* param); | |||||
| public static extern unsafe int llama_model_quantize(string fname_inp, string fname_out, LLamaModelQuantizeParams* param); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,15 +0,0 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace LLama.Native | |||||
| { | |||||
| internal class NativeInfo | |||||
| { | |||||
| internal static readonly int LLAMA_FILE_VERSION = 1; | |||||
| internal static readonly string LLAMA_FILE_MAGIC = "ggjt"; | |||||
| internal static readonly string LLAMA_FILE_MAGIC_UNVERSIONED = "ggml"; | |||||
| internal static readonly string LLAMA_SESSION_MAGIC = "ggsn"; | |||||
| internal static readonly int LLAMA_SESSION_VERSION = 1; | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Diagnostics; | |||||
| using System.Text; | using System.Text; | ||||
| using LLama.Exceptions; | using LLama.Exceptions; | ||||
| @@ -150,7 +151,7 @@ namespace LLama.Native | |||||
| var tokens = new int[count]; | var tokens = new int[count]; | ||||
| fixed (int* tokensPtr = &tokens[0]) | fixed (int* tokensPtr = &tokens[0]) | ||||
| { | { | ||||
| count = NativeApi.llama_tokenize_with_model(this, bytesPtr, tokensPtr, count, add_bos); | |||||
| NativeApi.llama_tokenize_with_model(this, bytesPtr, tokensPtr, count, add_bos); | |||||
| return tokens; | return tokens; | ||||
| } | } | ||||
| } | } | ||||
| @@ -102,7 +102,7 @@ namespace LLama | |||||
| /// <returns></returns> | /// <returns></returns> | ||||
| public static bool SignedByteToBool(sbyte value) | public static bool SignedByteToBool(sbyte value) | ||||
| { | { | ||||
| return value > 0 ? true : false; | |||||
| return value > 0; | |||||
| } | } | ||||
| } | } | ||||