diff --git a/LLama.Examples/LLama.Examples.csproj b/LLama.Examples/LLama.Examples.csproj
index ea281484..ec6bb10d 100644
--- a/LLama.Examples/LLama.Examples.csproj
+++ b/LLama.Examples/LLama.Examples.csproj
@@ -10,14 +10,14 @@
true
true
12
- 1701;1702;8604;SKEXP0001;SKEXP0052;SKEXP0003
+ 1701;1702;8604;SKEXP0001;SKEXP0050;SKEXP0052;SKEXP0003
-
-
-
+
+
+
diff --git a/LLama.KernelMemory/LLamaSharp.KernelMemory.csproj b/LLama.KernelMemory/LLamaSharp.KernelMemory.csproj
index e8b6af02..b32c0619 100644
--- a/LLama.KernelMemory/LLamaSharp.KernelMemory.csproj
+++ b/LLama.KernelMemory/LLamaSharp.KernelMemory.csproj
@@ -27,7 +27,7 @@
-
+
diff --git a/LLama.SemanticKernel/ChatCompletion/LLamaSharpChatCompletion.cs b/LLama.SemanticKernel/ChatCompletion/LLamaSharpChatCompletion.cs
index b1c0d347..7bcbaf7b 100644
--- a/LLama.SemanticKernel/ChatCompletion/LLamaSharpChatCompletion.cs
+++ b/LLama.SemanticKernel/ChatCompletion/LLamaSharpChatCompletion.cs
@@ -16,7 +16,7 @@ namespace LLamaSharp.SemanticKernel.ChatCompletion;
///
public sealed class LLamaSharpChatCompletion : IChatCompletionService
{
- private readonly StatelessExecutor _model;
+ private readonly ILLamaExecutor _model;
private ChatRequestSettings defaultRequestSettings;
private readonly IHistoryTransform historyTransform;
private readonly ITextStreamTransform outputTransform;
@@ -36,7 +36,7 @@ public sealed class LLamaSharpChatCompletion : IChatCompletionService
};
}
- public LLamaSharpChatCompletion(StatelessExecutor model,
+ public LLamaSharpChatCompletion(ILLamaExecutor model,
ChatRequestSettings? defaultRequestSettings = default,
IHistoryTransform? historyTransform = null,
ITextStreamTransform? outputTransform = null)
diff --git a/LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj b/LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj
index 8006b767..80b2e2cc 100644
--- a/LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj
+++ b/LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj
@@ -10,39 +10,42 @@
enable
enable
- 0.8.0
- Tim Miller, Xbotter
- SciSharp STACK
- true
- MIT, SciSharp STACK $([System.DateTime]::UtcNow.ToString(yyyy))
- https://github.com/SciSharp/LLamaSharp
- git
- https://avatars3.githubusercontent.com/u/44989469?s=200&v=4
- LLama, LLM, GPT, ChatGPT, semantic-kernel, SciSharp
-
- The integration of LLamaSharp and Microsoft semantic-kernel.
-
-
- Support integration with semantic-kernel
-
- MIT
- packages
- AnyCPU;x64;Arm64
- LLamaSharp.semantic-kernel
- Debug;Release;GPU
- SKEXP0001,SKEXP0052
+ 0.8.0
+ Tim Miller, Xbotter
+ SciSharp STACK
+ true
+ MIT, SciSharp STACK $([System.DateTime]::UtcNow.ToString(yyyy))
+ https://github.com/SciSharp/LLamaSharp
+ git
+ https://avatars3.githubusercontent.com/u/44989469?s=200&v=4
+ LLama, LLM, GPT, ChatGPT, semantic-kernel, SciSharp
+
+ The integration of LLamaSharp and Microsoft semantic-kernel.
+
+
+ Support integration with semantic-kernel
+
+ MIT
+ packages
+ AnyCPU;x64;Arm64
+ LLamaSharp.semantic-kernel
+ Debug;Release;GPU
+ SKEXP0001,SKEXP0052
-
+
+
+
+
+
-
-
-
-
+
+
+
diff --git a/LLama.Unittest/LLama.Unittest.csproj b/LLama.Unittest/LLama.Unittest.csproj
index f6bebea7..d48b308e 100644
--- a/LLama.Unittest/LLama.Unittest.csproj
+++ b/LLama.Unittest/LLama.Unittest.csproj
@@ -14,6 +14,7 @@
+
diff --git a/LLama.Unittest/SemanticKernel/ExtensionMethodsTests.cs b/LLama.Unittest/SemanticKernel/ExtensionMethodsTests.cs
new file mode 100644
index 00000000..dfcef182
--- /dev/null
+++ b/LLama.Unittest/SemanticKernel/ExtensionMethodsTests.cs
@@ -0,0 +1,50 @@
+using Xunit;
+using LLama;
+using LLama.Abstractions;
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Services;
+using System;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Text;
+using static LLama.LLamaTransforms;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading;
+using LLamaSharp.SemanticKernel.ChatCompletion;
+
+namespace LLamaSharp.SemanticKernel.Tests
+{
+ public class ExtensionMethodsTests
+ {
+ [Fact]
+ public void ToLLamaSharpChatHistory_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var chatHistory = new Microsoft.SemanticKernel.ChatCompletion.ChatHistory();
+ bool ignoreCase = true;
+
+ // Act
+ var result = ExtensionMethods.ToLLamaSharpChatHistory(
+ chatHistory,
+ ignoreCase);
+
+ // Assert
+ Assert.NotNull(result);
+ }
+
+ [Fact]
+ public void ToLLamaSharpInferenceParams_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var requestSettings = new ChatRequestSettings();
+
+ // Act
+ var result = ExtensionMethods.ToLLamaSharpInferenceParams(
+ requestSettings);
+
+ // Assert
+ Assert.NotNull(result);
+ }
+ }
+}
diff --git a/LLama.Unittest/SemanticKernel/LLamaSharpChatCompletionTests.cs b/LLama.Unittest/SemanticKernel/LLamaSharpChatCompletionTests.cs
new file mode 100644
index 00000000..30211be7
--- /dev/null
+++ b/LLama.Unittest/SemanticKernel/LLamaSharpChatCompletionTests.cs
@@ -0,0 +1,85 @@
+using Xunit;
+using Moq;
+using LLama;
+using LLama.Abstractions;
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.ChatCompletion;
+using Microsoft.SemanticKernel.Services;
+using System;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Text;
+using static LLama.LLamaTransforms;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace LLamaSharp.SemanticKernel.ChatCompletion.Tests
+{
+ public class LLamaSharpChatCompletionTests
+ {
+ private Mock mockStatelessExecutor;
+
+ public LLamaSharpChatCompletionTests()
+ {
+ this.mockStatelessExecutor = new Mock();
+ }
+
+ private LLamaSharpChatCompletion CreateLLamaSharpChatCompletion()
+ {
+ return new LLamaSharpChatCompletion(
+ this.mockStatelessExecutor.Object,
+ null,
+ null,
+ null);
+ }
+
+ [Fact]
+ public async Task GetChatMessageContentsAsync_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var unitUnderTest = this.CreateLLamaSharpChatCompletion();
+ ChatHistory chatHistory = new ChatHistory();
+ PromptExecutionSettings? executionSettings = null;
+ Kernel? kernel = null;
+ CancellationToken cancellationToken = default;
+ mockStatelessExecutor.Setup(e => e.InferAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new List { "test" }.ToAsyncEnumerable());
+
+ // Act
+ var result = await unitUnderTest.GetChatMessageContentsAsync(
+ chatHistory,
+ executionSettings,
+ kernel,
+ cancellationToken);
+
+ // Assert
+ Assert.True(result.Count > 0);
+ }
+
+ [Fact]
+ public async Task GetStreamingChatMessageContentsAsync_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var unitUnderTest = this.CreateLLamaSharpChatCompletion();
+ ChatHistory chatHistory = new ChatHistory();
+ PromptExecutionSettings? executionSettings = null;
+ Kernel? kernel = null;
+ CancellationToken cancellationToken = default;
+
+ mockStatelessExecutor.Setup(e => e.InferAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new List { "test" }.ToAsyncEnumerable());
+
+ // Act
+ await foreach (var result in unitUnderTest.GetStreamingChatMessageContentsAsync(
+ chatHistory,
+ executionSettings,
+ kernel,
+ cancellationToken))
+ {
+ // Assert
+ Assert.NotNull(result);
+ }
+ }
+ }
+}
diff --git a/LLama.Unittest/SemanticKernel/LLamaSharpTextCompletionTests.cs b/LLama.Unittest/SemanticKernel/LLamaSharpTextCompletionTests.cs
new file mode 100644
index 00000000..9cb05e87
--- /dev/null
+++ b/LLama.Unittest/SemanticKernel/LLamaSharpTextCompletionTests.cs
@@ -0,0 +1,87 @@
+using Xunit;
+using Moq;
+using LLama;
+using LLama.Abstractions;
+using Microsoft.SemanticKernel;
+using Microsoft.SemanticKernel.Services;
+using System;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Text;
+using static LLama.LLamaTransforms;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace LLamaSharp.SemanticKernel.TextCompletion.Tests
+{
+ public class LLamaSharpTextCompletionTests : IDisposable
+ {
+ private MockRepository mockRepository;
+ private Mock mockExecutor;
+
+ public LLamaSharpTextCompletionTests()
+ {
+ this.mockRepository = new MockRepository(MockBehavior.Strict);
+ this.mockExecutor = this.mockRepository.Create();
+ }
+
+ public void Dispose()
+ {
+ this.mockRepository.VerifyAll();
+ }
+
+ private LLamaSharpTextCompletion CreateLLamaSharpTextCompletion()
+ {
+ return new LLamaSharpTextCompletion(
+ this.mockExecutor.Object);
+ }
+
+ [Fact]
+ public async Task GetTextContentsAsync_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var unitUnderTest = this.CreateLLamaSharpTextCompletion();
+ string prompt = "Test";
+ PromptExecutionSettings? executionSettings = null;
+ Kernel? kernel = null;
+ CancellationToken cancellationToken = default;
+ mockExecutor.Setup(e => e.InferAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new List { "test" }.ToAsyncEnumerable());
+
+ // Act
+ var result = await unitUnderTest.GetTextContentsAsync(
+ prompt,
+ executionSettings,
+ kernel,
+ cancellationToken);
+
+ // Assert
+ Assert.True(result.Count > 0);
+ }
+
+ [Fact]
+ public async Task GetStreamingTextContentsAsync_StateUnderTest_ExpectedBehavior()
+ {
+ // Arrange
+ var unitUnderTest = this.CreateLLamaSharpTextCompletion();
+ string prompt = "Test";
+ PromptExecutionSettings? executionSettings = null;
+ Kernel? kernel = null;
+ CancellationToken cancellationToken = default;
+ mockExecutor.Setup(e => e.InferAsync(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new List { "test" }.ToAsyncEnumerable());
+
+ // Act
+ await foreach (var result in unitUnderTest.GetStreamingTextContentsAsync(
+ prompt,
+ executionSettings,
+ kernel,
+ cancellationToken))
+ {
+ // Assert
+ Assert.NotNull(result);
+ }
+ }
+ }
+}