Skip to content

Commit

Permalink
Latest changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rliberoff committed Jan 17, 2024
1 parent 5ed4bb0 commit 2ec33fe
Show file tree
Hide file tree
Showing 49 changed files with 401 additions and 203 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set Java for SonarCloud
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '21'

- name: Using .NET from 'global.json'
uses: actions/setup-dotnet@v3
Expand Down
28 changes: 21 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Previous classification is not required if changes are simple or all belong to t

### Important

This version updates the `Semantic Kernel` library from version `1.0.0-beta8` to `1.0.1`, which introduces a lot of breaking changes in the code.
This version updates the `Semantic Kernel` library from version `1.0.0-beta8` to `1.1.0`, which introduces a lot of breaking changes in the code.

Sadly, some features from `Semantic Kernel` that we might have been used are marked as ***experimental*** and produce warnings that do not allow the compilation of the code. To use these features, these warnings must be ignored explicitly per project. The following is a list of these warnings and the affected projects:
Sadly, some features from `Semantic Kernel` that we might have been using, are marked as ***experimental*** and produce warnings that do not allow the compilation of the code. To use these features, these warnings must be ignored explicitly per project. The following is a list of these warnings and the affected projects:

- SKEXP0001:
- `Encamina.Enmarcha.SemanticKernel`
Expand All @@ -43,6 +43,8 @@ Sadly, some features from `Semantic Kernel` that we might have been used are mar

### Braking Changes

- Replaced class `Completition` for `Completion` in `Encamina.Enmarcha.AI.OpenAI.Abstractions`. It was misspelled.
- Class `SemanticKernelOptions` does not exists anymore. It has been replaced by `AzureOpenAIOptions` from `Encamina.Enmarcha.AI.OpenAI.Abstractions`.
- The following references were updated due to changes in `Semantic Kernel` version `1.0.1`:
- Changed `IKernel` for `Kernel`.
- Changed `ISKFunction` for `KernelFunction` or `KernelPlugin`.
Expand All @@ -56,28 +58,40 @@ Sadly, some features from `Semantic Kernel` that we might have been used are mar
- `GetSemanticFunctionUsedTokensAsync` is replaced by `GetKernelFunctionUsedTokensAsync`.
- `ImportSemanticPluginsFromAssembly` is replaced by `ImportPromptFunctionsFromAssembly`.
- Extension method `GetSemanticFunctionPromptAsync` is no longer available. It is replaced by `GetKernelFunctionPromptAsync`.
- Extension method `ImportQuestionAnsweringPlugin` has different signature.
- Extension method `ImportQuestionAnsweringPluginWithMemory` has different signature.
- Extension method `ImportChatWithHistoryPluginUsingCosmosDb` has different signature.
- The format of prompt function configuration files `config.json` has been modified.

### Major Changes

- Updated `Semantic Kernel` from `1.0.0-beta8` to `1.0.1` (first final version of `Semantic Kernel`).
- Updated `Azure.Core` from version `1.36.0` to `1.37.0`.
- Updated `Azure.AI.OpenAI` from version `1.0.0-beta.6` to `1.0.0-beta.12`.
- Updated `Bogus` from version `34.0.2` to `35.3.0`.
- Updated `Bogus` from version `34.0.2` to `35.4.0`.
- Updated `Microsoft.AspNetCore.Authentication.JwtBearer` from version `8.0.0` to `8.0.1`.
- Updated `Microsoft.AspNetCore.Authentication.OpenIdConnect` from version `8.0.0` to `8.0.1`.
- Updated `Microsoft.Azure.Cosmos` from version `3.37.0` to `3.37.1`.
- Updated `Microsoft.EntityFrameworkCore` from version `8.0.0` to `8.0.1`.
- Updated `Microsoft.Extensions.Options` from version `8.0.0` to `8.0.1`.
- Updated `SharpToken` from version `1.2.12` to `1.2.14`.
- Updated `xunit` from version `2.6.2` to `2.6.5`.
- Updated `xunit.analyzers` from version `1.6.0` to `1.9.0`.
- Updated `xunit.extensibility.core` from version `2.6.2` to `2.6.5`.
- Updated `xunit` from version `2.6.2` to `2.6.6`.
- Updated `xunit.analyzers` from version `1.6.0` to `1.10.0`.
- Updated `xunit.extensibility.core` from version `2.6.2` to `2.6.6`.
- Updated `xunit.runner.visualstudio` from version `2.5.4` to `2.5.6`.
- Updated `StyleCop.Analyzers` from version `1.2.0-beta.507` to `1.2.0-beta.556`.
- Updated `System.Text.Json` from version `8.0.0` to `8.0.1`.
- Updated version from `8.0.3` to `8.1.0` due to all the major and breaking changes.
- Updated some `README.md` files changing `IKernel` for `Kernel`.
- Updated and added new unit tests to cover the main "happy path" of implementations that use `Semnantic Kernel`.

### Minor Changes

- Updated prompt function configuration files (`config.json`) to new format.
- Renamed files `IKernelExtensions` to `KernelExtensions.cs`.
- Fixed token counting in `ChatWithHistoryPlugin.cs`.
- Updated prompt function configuration files (`config.json`) to new format.
- Updated sample projects.
- Fixed some typos and grammatical errors.

## [8.0.3]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.0.1-alpha" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.1.0-alpha" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Encamina.Enmarcha.AI.OpenAI.Azure\Encamina.Enmarcha.AI.OpenAI.Azure.csproj" />
<ProjectReference Include="..\..\..\src\Encamina.Enmarcha.SemanticKernel.Connectors.Memory\Encamina.Enmarcha.SemanticKernel.Connectors.Memory.csproj" />
<ProjectReference Include="..\..\..\src\Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering\Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Encamina.Enmarcha.SemanticKernel.Abstractions;
using Encamina.Enmarcha.AI.OpenAI.Azure;
using Encamina.Enmarcha.SemanticKernel.Abstractions;
using Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering;

using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -26,21 +27,21 @@ public static async Task RunAsync()
hostBuilder.ConfigureServices((hostContext, services) =>
{
// Add Semantic Kernel options
services.AddOptions<SemanticKernelOptions>().Bind(hostContext.Configuration.GetSection(nameof(SemanticKernelOptions))).ValidateDataAnnotations().ValidateOnStart();
services.AddOptions<AzureOpenAIOptions>().Bind(hostContext.Configuration.GetSection(nameof(AzureOpenAIOptions))).ValidateDataAnnotations().ValidateOnStart();

services.AddScoped(sp =>
{
// Get semantic kernel options
var options = hostContext.Configuration.GetRequiredSection(nameof(SemanticKernelOptions)).Get<SemanticKernelOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(SemanticKernelOptions)}");
var options = hostContext.Configuration.GetRequiredSection(nameof(AzureOpenAIOptions)).Get<AzureOpenAIOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(AzureOpenAIOptions)}");

// Initialize semantic kernel
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(options.ChatModelDeploymentName, options.Endpoint.ToString(), options.Key)
.Build();

// Import Question Answering plugin
kernel.ImportQuestionAnsweringPlugin(sp, ILengthFunctions.LengthByTokenCount);
kernel.ImportQuestionAnsweringPlugin(options, ILengthFunctions.LengthByTokenCount);

return kernel;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Encamina.Enmarcha.SemanticKernel.Abstractions;
using Encamina.Enmarcha.AI.OpenAI.Azure;
using Encamina.Enmarcha.SemanticKernel.Abstractions;
using Encamina.Enmarcha.SemanticKernel.Plugins.QuestionAnswering;

using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -27,11 +28,11 @@ public static async Task RunAsync()
hostBuilder.ConfigureServices((hostContext, services) =>
{
// Get semantic kernel options
var options = hostContext.Configuration.GetRequiredSection(nameof(SemanticKernelOptions)).Get<SemanticKernelOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(SemanticKernelOptions)}");
var options = hostContext.Configuration.GetRequiredSection(nameof(AzureOpenAIOptions)).Get<AzureOpenAIOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(AzureOpenAIOptions)}");

// Add Semantic Kernel options
services.AddOptions<SemanticKernelOptions>().Bind(hostContext.Configuration.GetSection(nameof(SemanticKernelOptions))).ValidateDataAnnotations().ValidateOnStart();
services.AddOptions<AzureOpenAIOptions>().Bind(hostContext.Configuration.GetSection(nameof(AzureOpenAIOptions))).ValidateDataAnnotations().ValidateOnStart();

// Here use any desired implementation (Qdrant, Volatile...)
services.AddSingleton<IMemoryStore, VolatileMemoryStore>()
Expand All @@ -46,7 +47,7 @@ public static async Task RunAsync()
.Build();

// Import Question Answering plugin
kernel.ImportQuestionAnsweringPluginWithMemory(sp, ILengthFunctions.LengthByTokenCount);
kernel.ImportQuestionAnsweringPluginWithMemory(options, sp.GetRequiredService<ISemanticTextMemory>(), ILengthFunctions.LengthByTokenCount);

return kernel;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

internal static class Program
{
private static async Task Main(string[] args)
private static async Task Main(string[] _)
{
await ExampleQuestionAnsweringFromContext.RunAsync();
await ExampleQuestionAnsweringFromMemory.RunAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,12 @@ public async Task<string> TestQuestionAnsweringFromMemoryAsync()
var input = "What period occurred the Industrial Revolution?";
var arguments = new KernelArguments()
{
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.Question] =
input,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.CollectionSeparator] =
",",
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.CollectionsStr] =
"my-collection",
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.MinRelevance] =
0.8,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.ResultsLimit] =
1,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.ResponseTokenLimit] =
300
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.Question] = input,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.CollectionSeparator] = ",",
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.CollectionsStr] = "my-collection",
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.MinRelevance] = 0.8,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.ResultsLimit] = 1,
[PluginsInfo.QuestionAnsweringPlugin.Functions.QuestionAnsweringFromMemoryQuery.Parameters.ResponseTokenLimit] = 300
};

Console.WriteLine($"# Question: {input} \n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"SemanticKernelOptions": {
"AzureOpenAIOptions": {
"ChatModelName": "", // Name (sort of a unique identifier) of the model to use for chat.
"ChatModelDeploymentName": "", // Model deployment name on the LLM (for example OpenAI) to use for chat.
"EmbeddingsModelName": "", // Name (sort of a unique identifier) of the model to use for embeddings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Encamina.Enmarcha.AI.OpenAI.Azure\Encamina.Enmarcha.AI.OpenAI.Azure.csproj" />
<ProjectReference Include="..\..\..\src\Encamina.Enmarcha.SemanticKernel.Plugins.Text\Encamina.Enmarcha.SemanticKernel.Plugins.Text.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Encamina.Enmarcha.SemanticKernel.Abstractions;
using Encamina.Enmarcha.AI.OpenAI.Azure;
using Encamina.Enmarcha.SemanticKernel.Plugins.Text;

using Microsoft.Extensions.Configuration;
Expand All @@ -11,7 +11,7 @@ namespace Encamina.Enmarcha.Samples.SemanticKernel.Text;

internal static class Program
{
private static async Task Main(string[] args)
private static async Task Main(string[] _)
{
// Create and configure builder
var hostBuilder = new HostBuilder()
Expand All @@ -26,8 +26,8 @@ private static async Task Main(string[] args)
services.AddScoped(_ =>
{
// Get semantic kernel options
var options = hostContext.Configuration.GetRequiredSection(nameof(SemanticKernelOptions)).Get<SemanticKernelOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(SemanticKernelOptions)}");
var options = hostContext.Configuration.GetRequiredSection(nameof(AzureOpenAIOptions)).Get<AzureOpenAIOptions>()
?? throw new InvalidOperationException(@$"Missing configuration for {nameof(AzureOpenAIOptions)}");

// Initialize semantic kernel
var kernel = Kernel.CreateBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"SemanticKernelOptions": {
"AzureOpenAIOptions": {
"ChatModelName": "", // Name (sort of a unique identifier) of the model to use for chat.
"ChatModelDeploymentName": "", // Model deployment name on the LLM (for example OpenAI) to use for chat.
"Endpoint": "", // URL for an LLM resource (like OpenAI). This should include protocol and host name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Encamina.Enmarcha.AI.IntentsPrediction.Abstractions;
/// </summary>
[SuppressMessage(@"Major Code Smell",
"S4035:Classes implementing \"IEquatable<T>\" should be sealed",
Justification = "Intended useage of this class requires it to be inheritable and implement the \"IEquatable<T>\" interface!")]
Justification = "Intended usage of this class requires it to be inheritable and implement the \"IEquatable<T>\" interface!")]
public class IntentKindBase : IEqualityComparer<IntentKindBase>, IEquatable<IntentKindBase>
{
private readonly string value;
Expand All @@ -29,8 +29,8 @@ protected IntentKindBase(string value)
/// <summary>
/// Determines if two <see cref="IntentKindBase"/> values are the same.
/// </summary>
/// <param name="left">The left part from the equality comparisson.</param>
/// <param name="right">The right part from the equality comparisson.</param>
/// <param name="left">The left part from the equality comparison.</param>
/// <param name="right">The right part from the equality comparison.</param>
/// <returns>
/// Returns <see langword="true"/> if <paramref name="left"/> is the same as <paramref name="right"/>, otherwise returns <see langword="false"/>.
/// </returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Azure.AI.Language.Conversations" Version="1.1.0" />
<PackageReference Include="Azure.Core" Version="1.36.0" />
<PackageReference Include="Azure.Core" Version="1.37.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace Encamina.Enmarcha.AI.OpenAI.Abstractions;

/// <summary>
/// Represents a completition generated by OpenAI.
/// Represents a completion generated by OpenAI.
/// </summary>
public class Completition
public class Completion
{
/// <summary>
/// Gets the text of the generatad completion .
/// Gets the text of the generated completion .
/// </summary>
public string Text { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public class CompletionResult : IdentifiableBase<string>
/// <summary>
/// Gets the completions generated.
/// </summary>
public IEnumerable<Completition> Completitions { get; init; }
public IEnumerable<Completion> Completitions { get; init; }
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Encamina.Enmarcha.Core\Encamina.Enmarcha.Core.csproj" />
<ProjectReference Include="..\Encamina.Enmarcha.Entities.Abstractions\Encamina.Enmarcha.Entities.Abstractions.csproj" />
<ProjectReference Include="..\Encamina.Enmarcha.Entities\Encamina.Enmarcha.Entities.csproj" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 2ec33fe

Please sign in to comment.