Skip to content

Commit

Permalink
feat(Semantic Kernel Upgrade): Upgrading to RC kernel.
Browse files Browse the repository at this point in the history
  • Loading branch information
frostaura committed Jan 6, 2024
1 parent 432f505 commit 46963de
Show file tree
Hide file tree
Showing 35 changed files with 414 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace FrostAura.Libraries.Communication.Tests.Integration.Services
{
public class TwilioSmsServiceTests
{
[Fact]
[Fact(Skip = "Integration Test")]
public async Task SendMessageAsync_WithValidParams_ShouldSendSms()
{
// Setup
Expand All @@ -38,7 +38,7 @@ public async Task SendMessageAsync_WithValidParams_ShouldSendSms()
await communicator.SendMessageAsync(request, CancellationToken.None);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task SendAndWaitForResponseAsync_WithValidParams_ShouldSendAndReceiveSms()
{
// Setup
Expand Down
6 changes: 3 additions & 3 deletions src/FrostAura.Libraries.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Communication.Tests", "Comm
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Communication.Tests.Integration", "Communication.Tests.Integration\Communication.Tests.Integration.csproj", "{B42FAAFB-C220-41F5-A6D4-92DD6A82FCE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Finance", "Finance\FrostAura.Libraries.Finance.csproj", "{B416A044-CAB3-4F9A-99EB-0F9774D2D926}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostAura.Libraries.Finance", "Finance\FrostAura.Libraries.Finance.csproj", "{B416A044-CAB3-4F9A-99EB-0F9774D2D926}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Finance.Tests", "Finance.Tests\FrostAura.Libraries.Finance.Tests.csproj", "{5A1C01AF-9480-4525-B3E4-DB9C90629F80}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostAura.Libraries.Finance.Tests", "Finance.Tests\FrostAura.Libraries.Finance.Tests.csproj", "{5A1C01AF-9480-4525-B3E4-DB9C90629F80}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Intelligence", "Intelligence", "{E292F563-CF51-47B7-A81C-D0FE8FC4C02A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semantic.Core", "Semantic.Core\FrostAura.Libraries.Intelligence.Semantic.Core.csproj", "{D063671B-2B7E-4A03-ACB8-10A9D512B15F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semantic.Core", "Semantic.Core\Semantic.Core.csproj", "{D063671B-2B7E-4A03-ACB8-10A9D512B15F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semantic.Core.Tests", "Semantic.Core.Tests\Semantic.Core.Tests.csproj", "{11FEC351-432F-4B92-BD60-1028B84BCF20}"
EndProject
Expand Down
18 changes: 9 additions & 9 deletions src/Semantic.Core.Tests/Semantic.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.4" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.1.23419.4" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -55,12 +55,12 @@
<Folder Include="Thoughts\Finance\" />
<Folder Include="Thoughts\Chains\Finance\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semantic.Core\FrostAura.Libraries.Intelligence.Semantic.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="harvard.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semantic.Core\Semantic.Core.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ public void Constructor_WithValidParams_ShouldConstruct()
}

[Fact]
public async Task ExecuteChainAsync_WithInvalidInput_ShouldThrow()
public async Task TranscribeAudioFileAsync_WithInvalidInput_ShouldThrow()
{
var serviceProvider = Substitute.For<IServiceProvider>();
var serviceCollection = new ServiceCollection()
.AddSemanticCore(Config.SEMANTIC_CONFIG);
var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = Substitute.For<ILogger<AudioTranscriptionChain>>();
var instance = new AudioTranscriptionChain(serviceProvider, logger);
string input = default;
string audioFilePath = default;

var actual = await Assert.ThrowsAsync<ArgumentNullException>(async () => await instance.ExecuteChainAsync(input));
var actual = await Assert.ThrowsAsync<ArgumentNullException>(async () => await instance.TranscribeAudioFileAsync(audioFilePath));

Assert.Equal(nameof(input), actual.ParamName);
Assert.Equal(nameof(audioFilePath), actual.ParamName);
}

[Fact]
public async Task ExecuteChainAsync_WithValidInput_ShouldCallInvokeAsyncAsync()
public async Task TranscribeAudioFileAsync_WithValidInput_ShouldCallInvokeAsyncAsync()
{
var serviceCollection = new ServiceCollection()
.AddSemanticCore(Config.SEMANTIC_CONFIG);
Expand All @@ -71,7 +73,7 @@ public async Task ExecuteChainAsync_WithValidInput_ShouldCallInvokeAsyncAsync()
var input = "./harvard.wav";
var expected = "The stale smell of old beer lingers. It takes heat to bring out the odor. A cold dip restores health and zest. A salt pickle tastes fine with ham. Tacos al pastor are my favorite. A zestful food is the hot cross bun.";

var actual = await instance.ExecuteChainAsync(input);
var actual = await instance.TranscribeAudioFileAsync(input);

Assert.Contains(expected, actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ public void Constructor_WithValidParams_ShouldConstruct()
Assert.NotEmpty(actual.ChainOfThoughts);
}

[Fact]
public async Task ExecuteChainAsync_WithInvalidInput_ShouldThrow()
{
var serviceProvider = Substitute.For<IServiceProvider>();
var logger = Substitute.For<ILogger<MemoryCommitChain>>();
var instance = new MemoryCommitChain(serviceProvider, logger);
string input = default;

var actual = await Assert.ThrowsAsync<ArgumentNullException>(async () => await instance.ExecuteChainAsync(input));

Assert.Equal(nameof(input), actual.ParamName);
}

[Fact]
public async Task ExecuteChainAsync_WithValidInput_ShouldCallCommitToMemoryAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ public void Constructor_WithValidParams_ShouldConstruct()
Assert.NotEmpty(actual.ChainOfThoughts);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task ExecuteChainAsync_WithValidInput_ShouldCallInvokeAsyncAsync()
{
var serviceCollection = new ServiceCollection()
.AddSemanticCore(Config.SEMANTIC_CONFIG);
var serviceProvider = serviceCollection.BuildServiceProvider();
var logger = Substitute.For<ILogger<GetFNBAccountBalancesChain>>();
var instance = new GetFNBAccountBalancesChain(serviceProvider, logger);
var input = string.Empty;

var actual = await instance.ExecuteChainAsync(input);
var actual = await instance.ExecuteChainAsync();

Assert.NotEmpty(actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,18 @@ public void Constructor_WithValidParams_ShouldConstruct()
[Fact]
public async Task ExecuteChainAsync_WithInvalidInput_ShouldThrow()
{
var serviceProvider = Substitute.For<IServiceProvider>();
var serviceCollection = new ServiceCollection()
.AddSemanticCore(Config.SEMANTIC_CONFIG);
var logger = Substitute.For<ILogger<YouTubeShortFactualVideoGenerationChain>>();
var instance = new YouTubeShortFactualVideoGenerationChain(serviceProvider, logger);
var instance = new YouTubeShortFactualVideoGenerationChain(serviceCollection.BuildServiceProvider(), logger);
string input = default;

var actual = await Assert.ThrowsAsync<ArgumentNullException>(async () => await instance.ExecuteChainAsync(input));

Assert.Equal(nameof(input), actual.ParamName);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task ExecuteChainAsync_WithValidInput_ShouldCallInvokeAsyncAsync()
{
var serviceCollection = new ServiceCollection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task TextToSpeechAsync_WithInvalidText_ShouldThrow()
Assert.Equal(nameof(text), actual.ParamName);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task TextToSpeechAsync_WithValidText_ShouldReturnFilePath()
{
var elevenLabsConfig = Substitute.For<IOptions<ElevenLabsConfig>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LanguageModelThoughtsTests
[Fact]
public void Constructor_WithInvalidKernel_ShouldThrow()
{
IKernel kernel = null;
Kernel kernel = null;
ILogger<LanguageModelThoughts> logger = Substitute.For<ILogger<LanguageModelThoughts>>();

var actual = Assert.Throws<ArgumentNullException>(() => new LanguageModelThoughts(kernel, logger));
Expand All @@ -23,7 +23,7 @@ public void Constructor_WithInvalidKernel_ShouldThrow()
[Fact]
public void Constructor_WithInvalidLogger_ShouldThrow()
{
IKernel kernel = Substitute.For<IKernel>();
Kernel kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel();
ILogger<LanguageModelThoughts> logger = null;

var actual = Assert.Throws<ArgumentNullException>(() => new LanguageModelThoughts(kernel, logger));
Expand All @@ -34,7 +34,7 @@ public void Constructor_WithInvalidLogger_ShouldThrow()
[Fact]
public void Constructor_WithValidParams_ShouldConstruct()
{
var kernel = Substitute.For<IKernel>();
var kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel();
var logger = Substitute.For<ILogger<LanguageModelThoughts>>();

var actual = new LanguageModelThoughts(kernel, logger);
Expand Down
20 changes: 9 additions & 11 deletions src/Semantic.Core.Tests/Thoughts/Cognitive/MemoryThoughtsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class MemoryThoughtsTests
[Fact]
public void Constructor_WithInvalidKernel_ShouldThrow()
{
IKernel kernel = null;
Kernel kernel = null;
ILogger<MemoryThoughts> logger = Substitute.For<ILogger<MemoryThoughts>>();

var actual = Assert.Throws<ArgumentNullException>(() => new MemoryThoughts(kernel, logger));
Expand All @@ -24,7 +24,7 @@ public void Constructor_WithInvalidKernel_ShouldThrow()
[Fact]
public void Constructor_WithInvalidLogger_ShouldThrow()
{
IKernel kernel = Substitute.For<IKernel>();
var kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel();
ILogger<MemoryThoughts> logger = null;

var actual = Assert.Throws<ArgumentNullException>(() => new MemoryThoughts(kernel, logger));
Expand All @@ -35,7 +35,7 @@ public void Constructor_WithInvalidLogger_ShouldThrow()
[Fact]
public void Constructor_WithValidParams_ShouldConstruct()
{
var kernel = Substitute.For<IKernel>();
var kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel();
var logger = Substitute.For<ILogger<MemoryThoughts>>();

var actual = new MemoryThoughts(kernel, logger);
Expand Down Expand Up @@ -74,9 +74,9 @@ public async Task CommitToMemoryAsync_WithInvalidSource_ShouldThrow()
[Fact]
public async Task CommitToMemoryAsync_WithValidInput_ShouldRespond()
{
var kernel = Substitute.For<IKernel>();
var memory = Substitute.For<ISemanticTextMemory>();
kernel.Memory.ReturnsForAnyArgs(memory);
var kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel(memory);

var logger = Substitute.For<ILogger<MemoryThoughts>>();
var instance = new MemoryThoughts(kernel, logger);
string input = new string(Enumerable.Range(0, 2200)
Expand All @@ -85,8 +85,7 @@ public async Task CommitToMemoryAsync_WithValidInput_ShouldRespond()

var actual = await instance.CommitToMemoryAsync(input, "Test");

kernel
.Memory
memory
.ReceivedWithAnyArgs(3)
.SaveInformationAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
}
Expand All @@ -107,17 +106,16 @@ public async Task RecallFromMemoryAsync_WithInvalidMemory_ShouldThrow()
[Fact]
public async Task RecallFromMemoryAsync_WithValidInput_ShouldRespond()
{
var kernel = Substitute.For<IKernel>();
var memory = Substitute.For<ISemanticTextMemory>();
kernel.Memory.ReturnsForAnyArgs(memory);
var kernel = Config.SEMANTIC_CONFIG.GetComprehensiveKernel(memory);

var logger = Substitute.For<ILogger<MemoryThoughts>>();
var instance = new MemoryThoughts(kernel, logger);
string input = "What is my name?";

var actual = await instance.RecallFromMemoryAsync(input);

kernel
.Memory
memory
.ReceivedWithAnyArgs(1)
.SearchAsync(Arg.Any<string>(), Arg.Any<string>());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Semantic.Core.Tests/Thoughts/Finance/FNBThoughtsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Constructor_WithValidParams_ShouldConstruct()
Assert.NotNull(actual);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task LoadTextAsync_WithValidInput_ShouldRespond()
{
var fnbOptions = Substitute.For<IOptions<FNBConfig>>();
Expand All @@ -75,7 +75,7 @@ public async Task LoadTextAsync_WithValidInput_ShouldRespond()
var serviceProvider = serviceCollection.BuildServiceProvider();
var instance = new FNBThoughts(serviceProvider, fnbOptions, logger);

var actual = await instance.GetFNBAccountBalancesAsync();
var actual = await instance.GetFNBAccountBalancesRawAsync();

Assert.NotEmpty(actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task DownloadAndGetStockVideoAsync_WithInvalidSearchQuery_ShouldThr
Assert.Equal(nameof(searchQuery), actual.ParamName);
}

[Fact]
[Fact(Skip = "Integration Test")]
public async Task DownloadAndGetStockVideoAsync_WithValidInputs_ShouldRespond()
{
var httpClientFactory = Substitute.For<IHttpClientFactory>();
Expand Down
Loading

0 comments on commit 46963de

Please sign in to comment.