Skip to content

Commit

Permalink
Merge pull request #68 from Encamina/@rliberoff/improvements_and_new_…
Browse files Browse the repository at this point in the history
…features

Bump version from `8.1.1` to `8.1.2`. This is the new final version for release 8.1.2
  • Loading branch information
rliberoff authored Feb 1, 2024
2 parents b1f7128 + 4805751 commit cdcb0a3
Show file tree
Hide file tree
Showing 23 changed files with 267 additions and 44 deletions.
23 changes: 19 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ 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.1.0` to `1.2.0`, which introduces minor changes in the code.
This version updates the `Semantic Kernel` library from version `1.1.0` to `1.3.0`, which introduces minor changes in the code, mostly internal dependencies.

More information about these warnings is available here: https://github.com/microsoft/semantic-kernel/releases/tag/dotnet-1.2.0
For more information about these changes, please visit the following links:
- [Semantic Kernel release dotnet-1.2.0](https://github.com/microsoft/semantic-kernel/releases/tag/dotnet-1.2.0)
- [Semantic Kernel release dotnet-1.3.0](https://github.com/microsoft/semantic-kernel/releases/tag/dotnet-1.3.0)

### Breaking Changes
- Replace dependency with `IMemoryStore` for `IMemoryManager` in abstract class `MemoryStoreHandlerBase`. This affects internal types like the `EphemeralMemoryStoreHandler`.
Expand All @@ -37,6 +39,16 @@ More information about these warnings is available here: https://github.com/micr
- New `MemoryManager` property of type `IMemoryManager` in `IMemoryStoreHandler` interface to get read-only access to the underlaying memory manager.
- New `MemoryStore` property of type `IMemoryStore` in `IMemoryManager` interface to get read-only access to the underlaying memory store.
- Removed unnecessary `Guards` when adding a Memory Manager and the Ephemeral Memory Store Handler. The exceptions will be thrown by the DI engine itself.
- Added new class `AzureAISearchOptions` to configure connection parameters for Azure AI Search.
- Added new extension method `AddAzureAISearchMemoryStore` to add Azure AI Search as a valid vector database for a `IMemoryStore` instance.
- Improved extensions methods for adding `IMemoryStore` to consider debouncing when monitoring changes in parameters.
- Updated dependencies:
- Updated `Semantic Kernel` from `1.1.0` to `1.3.0` (third final version of `Semantic Kernel`).
- Updated `Microsoft.Azure.Cosmos` from version `3.37.1` to `3.38.0`.
- Updated `Microsoft.Bot.Builder.Azure` from version `4.21.2` to `4.22.0`.
- Updated `Microsoft.Bot.Builder.Azure.Blobs` from version `4.21.2` to `4.22.0`.
- Updated `Microsoft.Bot.Builder.Dialogs` from version `4.21.2` to `4.22.0`.
- Updated `Microsoft.Bot.Builder.Integration.ApplicationInsights.Core` from version `4.21.2` to `4.22.0`.

### Minor Changes
- Properties `CollectionNamePostfix` and `CollectionNamePrefix` from `MemoryStoreHandlerBase` are now `virtual` instead of `abstract`.
Expand All @@ -45,12 +57,15 @@ More information about these warnings is available here: https://github.com/micr
- Added new extension method `AddDefaultDocumentConnectorProvider` in `Encamina.Enmarcha.SemanticKernel.Connectors.Document` to get access to a default implementation of a `IDocumentConnector`.
- Updated sample projects with latest changes.
- Overloaded `AddDefaultDocumentConnectorProvider` and `AddDefaultDocumentContentExtractor` methods with a parameter to pass a function to calculate the length of a text and inject it as a dependency.
- Added Readme file to all solution's projects.
- Added `README.md` files to all projects in the solution when publishing to NuGet.org.
- Added event handler for `IMemoryStore` operations.
- Added new extension method `GetKernelPromptAsync` in `Encamina.Enmarcha.SemanticKernel.Extensions.KernelExtensions` to retrieve the final prompt for a given prompt using the arguments.
- Added new extension method `GetKernelFunctionUsedTokensFromPromptAsync` in `Encamina.Enmarcha.SemanticKernel.Extensions.KernelExtensions` to obtain the total number of tokens used in generating a prompt from an inline prompt function.
- Fixed `GetMaxTokensFromKernelFunction` in `Encamina.Enmarcha.SemanticKernel.Extensions.KernelExtensions`. Now, it considers whether the arguments are of type `OpenAIPromptExecutionSettings` when obtaining the MaxTokens.
- New `IMemoryStoreExtender` type which obsoleces the `IMemoryManager` type and its references.
- New `IMemoryStoreExtender` type which obsolesces the `IMemoryManager` type and its references. If you are using `IMemoryManager` start a plan to replace it with `IMemoryStoreExtender`.
- Added default values for `TextSplitterOptions` to allow using it without explicit configuration.
- Some code improvements to use .NET 8 and C# 12 features.
- Added new `Debouncer` class to provide mechanisms to prevent multiple calls to a method or event.

## [8.1.1]

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<PropertyGroup>
<VersionPrefix>8.1.2</VersionPrefix>
<VersionSuffix>preview-16</VersionSuffix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

<!--
Expand Down
11 changes: 9 additions & 2 deletions Enmarcha.sln
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.S
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering", "samples\SemanticKernel\Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering\Encamina.Enmarcha.Samples.SemanticKernel.QuestionAnswering.csproj", "{AA1E5E93-FE02-4395-9260-C7C869F22785}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encamina.Enmarcha.AI.Tests", "tst\Encamina.Enmarcha.AI.Tests\Encamina.Enmarcha.AI.Tests.csproj", "{7F3ECD81-28E6-4000-9005-1B2ABA8EC1C5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encamina.Enmarcha.SemanticKernel.Tests", "tst\Encamina.Enmarcha.SemanticKernel.Tests\Encamina.Enmarcha.SemanticKernel.Tests.csproj", "{7B6F4DC4-74E2-4013-8DBA-12B7AAAD5278}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.AI.Tests", "tst\Encamina.Enmarcha.AI.Tests\Encamina.Enmarcha.AI.Tests.csproj", "{7F3ECD81-28E6-4000-9005-1B2ABA8EC1C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Encamina.Enmarcha.SemanticKernel.Tests", "tst\Encamina.Enmarcha.SemanticKernel.Tests\Encamina.Enmarcha.SemanticKernel.Tests.csproj", "{7B6F4DC4-74E2-4013-8DBA-12B7AAAD5278}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encamina.Enmarcha.Data.AzureAISearch", "src\Encamina.Enmarcha.Data.AzureAISearch\Encamina.Enmarcha.Data.AzureAISearch.csproj", "{120ABEF3-3E36-434D-8EC7-E3B3F1817EAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -357,6 +360,10 @@ Global
{7B6F4DC4-74E2-4013-8DBA-12B7AAAD5278}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B6F4DC4-74E2-4013-8DBA-12B7AAAD5278}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B6F4DC4-74E2-4013-8DBA-12B7AAAD5278}.Release|Any CPU.Build.0 = Release|Any CPU
{120ABEF3-3E36-434D-8EC7-E3B3F1817EAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{120ABEF3-3E36-434D-8EC7-E3B3F1817EAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{120ABEF3-3E36-434D-8EC7-E3B3F1817EAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{120ABEF3-3E36-434D-8EC7-E3B3F1817EAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

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

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Encamina.Enmarcha.AI.Abstractions/TextSplitterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Encamina.Enmarcha.AI.Abstractions;

/// <summary>
/// Optiones for text splitters.
/// Options for text splitters.
/// </summary>
public class TextSplitterOptions
{
Expand All @@ -12,14 +12,14 @@ public class TextSplitterOptions
/// </summary>
[Required]
[Range(0, int.MaxValue)]
public int ChunkOverlap { get; init; }
public int ChunkOverlap { get; init; } = 10;

/// <summary>
/// Gets the number of elements (characters, tokens, etc.) in each chunk.
/// </summary>
[Required]
[Range(0, int.MaxValue)]
public int ChunkSize { get; init; }
public int ChunkSize { get; init; } = 100;

/// <summary>
/// Gets the collection of separator characters to use when splitting the text and creating chunks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public class FormToDictionaryModelBinder<TKey, TValue> : IModelBinder
/// <inheritdoc/>
public Task BindModelAsync(ModelBindingContext bindingContext)
{
if (bindingContext == null)
{
throw new ArgumentNullException(nameof(bindingContext));
}
ArgumentNullException.ThrowIfNull(bindingContext);

if (bindingContext.HttpContext.Request.HasFormContentType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.22.0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.22.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Encamina.Enmarcha.Bot/Encamina.Enmarcha.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<TreatAsUsed>true</TreatAsUsed>
<!-- This project needs this package reference to fix warning NU1701 -->
</PackageReference>
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Azure.Blobs" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.21.2" />
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.22.0" />
<PackageReference Include="Microsoft.Bot.Builder.Azure.Blobs" Version="4.22.0" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.22.0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.22.0" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.22.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>

Expand Down
36 changes: 36 additions & 0 deletions src/Encamina.Enmarcha.Core/Debouncer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Ignore Spelling: Debouncer

namespace Encamina.Enmarcha.Core;

/// <summary>
/// Provides mechanisms to prevent multiple bouncing calls to a method or event.
/// </summary>
public static class Debouncer
{
/// <summary>
/// Debounce a function from being called too frequently. This is often used in scenarios where you want to limit the rate of execution of a particular method or event.
/// </summary>
/// <typeparam name="T">The type of the argument to be passed to the function to be debounced.</typeparam>
/// <param name="function">The function to be debounced.</param>
/// <param name="milliseconds">The number of milliseconds to wait before calling the function again.</param>
/// <returns>A function that can be called to debounce the original function.</returns>
public static Action<T> Debounce<T>(Action<T> function, int milliseconds = 300)

Check warning on line 17 in src/Encamina.Enmarcha.Core/Debouncer.cs

View workflow job for this annotation

GitHub Actions / CI

Use the overloading mechanism instead of the optional parameters. (https://rules.sonarsource.com/csharp/RSPEC-2360)

Check warning on line 17 in src/Encamina.Enmarcha.Core/Debouncer.cs

View workflow job for this annotation

GitHub Actions / CI

Use the overloading mechanism instead of the optional parameters. (https://rules.sonarsource.com/csharp/RSPEC-2360)
{
var last = 0;

return arg =>
{
var current = Interlocked.Increment(ref last);

Task.Delay(milliseconds).ContinueWith(task =>
{
if (current == last)
{
function(arg);
}

task.Dispose();
});
};
}
}
24 changes: 24 additions & 0 deletions src/Encamina.Enmarcha.Data.AzureAISearch/AzureAISearchOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;

using Encamina.Enmarcha.Core.DataAnnotations;

namespace Encamina.Enmarcha.Data.AzureAISearch;

/// <summary>
/// Configuration options for setting up a connection to an Azure AI Search, and use it as a vector database.
/// </summary>
public sealed class AzureAISearchOptions
{
/// <summary>
/// Gets the Azure AI Search endpoint, , e.g. "https://enmarcha.search.windows.net".
/// </summary>
[Required]
[Uri]
public required Uri Endpoint { get; init; }

/// <summary>
/// Gets the Azure AI Search key.
/// </summary>
[Required]
public required string Key { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<ProjectReference Include="..\Encamina.Enmarcha.Core\Encamina.Enmarcha.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#if !NET7_0_OR_GREATER

namespace System.Runtime.CompilerServices;

/// <summary>
/// Indicates that compiler support for a particular feature is required for the location where this attribute is applied.
/// </summary>
/// <remarks>
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
/// </remarks>
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
/// <summary>
/// The <see cref="FeatureName"/> used for the ref structs C# feature.
/// </summary>
public const string RefStructs = nameof(RefStructs);

/// <summary>
/// The <see cref="FeatureName"/> used for the required members C# feature.
/// </summary>
public const string RequiredMembers = nameof(RequiredMembers);

/// <summary>
/// Initializes a new instance of the <see cref="CompilerFeatureRequiredAttribute"/> class.
/// </summary>
/// <param name="featureName">The name of the required compiler feature.</param>
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}

/// <summary>
/// Gets the name of the compiler feature.
/// </summary>
public string FeatureName { get; }

/// <summary>
/// Gets a value indicating whether the compiler can choose to allow access to the location
/// where this attribute is applied if it does not understand <see cref="FeatureName"/>.
/// </summary>
public bool IsOptional { get; init; }
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if NETSTANDARD2_1 || NETCOREAPP3_1 || NET45 || NET451 || NET452 || NET46 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48

using System.ComponentModel;

namespace System.Runtime.CompilerServices;

/// <summary>
/// Reserved to be used by the compiler for tracking metadata.
/// This class should not be used by developers in source code.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit
{
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if !NET7_0_OR_GREATER

namespace System.Runtime.CompilerServices;

/// <summary>
/// Specifies that a type has required members or that a member is required.
/// </summary>
/// <remarks>
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
internal sealed class RequiredMemberAttribute : Attribute
{
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if !NET7_0_OR_GREATER

namespace System.Diagnostics.CodeAnalysis;

/// <summary>
/// Specifies that this constructor sets all required members for the current type, and callers do not need to set any required members themselves.
/// </summary>
/// <remarks>
/// Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code.
/// </remarks>
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.37.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.38.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" Version="8.0.1" />
Expand Down Expand Up @@ -42,7 +42,7 @@
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.2.0" PrivateAssets="none" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.2.0" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.3.0" PrivateAssets="none" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.3.0" />
<PackageReference Include="SharpToken" Version="1.2.14" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Document" Version="1.2.0-alpha" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Document" Version="1.3.0-alpha" />
<PackageReference Include="PdfPig" Version="0.1.8" />
</ItemGroup>

Expand Down
Loading

0 comments on commit cdcb0a3

Please sign in to comment.