Skip to content

Commit

Permalink
Merge branch 'master' into WebUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
saddam213 committed Aug 23, 2023
2 parents a44ce18 + 42fc5e4 commit 13f1be5
Show file tree
Hide file tree
Showing 25 changed files with 19 additions and 72 deletions.
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/ChatSessionStripRoleName.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/ChatSessionWithRoleName.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/InstructModeExecute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/InteractiveModeExecute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/LoadAndSaveSession.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
1 change: 0 additions & 1 deletion LLama.Examples/NewVersion/LoadAndSaveState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LLama.Common;
using System.Text;

namespace LLama.Examples.NewVersion
{
Expand Down
5 changes: 1 addition & 4 deletions LLama.Examples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using LLama;
using LLama.Common;
using LLama.Examples;
using LLama.Examples.NewVersion;
using LLama.Examples.NewVersion;
using LLama.Examples.Old;

Console.WriteLine("======================================================================================================");
Expand Down
1 change: 0 additions & 1 deletion LLama.Unittest/BasicTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Text;
using LLama.Common;

namespace LLama.Unittest
Expand Down
3 changes: 1 addition & 2 deletions LLama.Unittest/GrammarTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using LLama.Common;
using LLama.Common;
using LLama.Native;

namespace LLama.Unittest
Expand Down
3 changes: 1 addition & 2 deletions LLama.Unittest/LLamaContextTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using LLama.Common;
using LLama.Common;

namespace LLama.Unittest
{
Expand Down
3 changes: 0 additions & 3 deletions LLama/Abstractions/IHistoryTransform.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using LLama.Common;
using System;
using System.Collections.Generic;
using System.Text;

namespace LLama.Abstractions
{
Expand Down
5 changes: 1 addition & 4 deletions LLama/Abstractions/ILLamaExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using LLama.Common;
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Threading;

namespace LLama.Abstractions
Expand Down
5 changes: 2 additions & 3 deletions LLama/Abstractions/ITextStreamTransform.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;

namespace LLama.Abstractions
{
Expand All @@ -15,6 +13,7 @@ public interface ITextStreamTransform
/// <param name="tokens"></param>
/// <returns></returns>
IEnumerable<string> Transform(IEnumerable<string> tokens);

/// <summary>
/// Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously.
/// </summary>
Expand Down
6 changes: 1 addition & 5 deletions LLama/Abstractions/ITextTransform.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace LLama.Abstractions
namespace LLama.Abstractions
{
/// <summary>
/// An interface for text transformations.
Expand Down
1 change: 0 additions & 1 deletion LLama/Common/ModelParams.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using LLama.Abstractions;
using System;
using System.Text;

namespace LLama.Common
{
Expand Down
5 changes: 1 addition & 4 deletions LLama/LLamaExecutorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,7 @@ protected virtual void TryReuseMathingPrefix()
public virtual IEnumerable<string> Infer(string text, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
if (inferenceParams is null)
{
inferenceParams = new InferenceParams();
}
inferenceParams ??= new InferenceParams();

InferStateArgs args = new InferStateArgs()
{
Expand Down
7 changes: 2 additions & 5 deletions LLama/LLamaInstructExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ protected override bool GetLoopCondition(InferStateArgs args)
/// <inheritdoc />
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);
if (_is_prompt_run)
{
Expand Down Expand Up @@ -160,7 +157,7 @@ protected override bool PostProcess(IInferenceParams inferenceParams, InferState

if (_pastTokensCount > 0 && args.WaitForInput)
{
extraOutputs = new string[] { "\n> " };
extraOutputs = new[] { "\n> " };
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LLama/LLamaInteractExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected override bool PostProcess(IInferenceParams inferenceParams, InferState

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;
}

Expand Down
3 changes: 1 addition & 2 deletions LLama/Native/LLamaContextParams.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace LLama.Native
{
public delegate void LlamaProgressCallback(float progress, IntPtr ctx);

[StructLayout(LayoutKind.Sequential)]
public struct LLamaContextParams
{
Expand Down
4 changes: 1 addition & 3 deletions LLama/Native/LLamaModelQuantizeParams.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Runtime.InteropServices;

namespace LLama.Native
namespace LLama.Native
{
/// <summary>
/// Quantizer parameters used in the native API
Expand Down
5 changes: 1 addition & 4 deletions LLama/Native/LLamaTokenData.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Runtime.InteropServices;

namespace LLama.Native
{
Expand Down
7 changes: 2 additions & 5 deletions LLama/Native/NativeApi.Quantize.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Runtime.InteropServices;

namespace LLama.Native
{
Expand All @@ -16,6 +13,6 @@ public partial class NativeApi
/// <remarks>not great API - very likely to change</remarks>
/// <returns>Returns 0 on success</returns>
[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);
}
}
15 changes: 0 additions & 15 deletions LLama/Native/NativeInfo.cs

This file was deleted.

3 changes: 2 additions & 1 deletion LLama/Native/SafeLlamaModelHandle.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Text;
using LLama.Exceptions;

Expand Down Expand Up @@ -150,7 +151,7 @@ public int[] Tokenize(string text, bool add_bos, Encoding encoding)
var tokens = new int[count];
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LLama/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static sbyte BoolToSignedByte(bool value)
/// <returns></returns>
public static bool SignedByteToBool(sbyte value)
{
return value > 0 ? true : false;
return value > 0;
}

}
Expand Down

0 comments on commit 13f1be5

Please sign in to comment.