diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3d40c5b66..955a2e2df 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -96,19 +96,19 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/examples/204-dotnet-ASP.NET-MVC-integration/204-dotnet-ASP.NET-MVC-integration.csproj b/examples/204-dotnet-ASP.NET-MVC-integration/204-dotnet-ASP.NET-MVC-integration.csproj
index 48004fe88..42030b6db 100644
--- a/examples/204-dotnet-ASP.NET-MVC-integration/204-dotnet-ASP.NET-MVC-integration.csproj
+++ b/examples/204-dotnet-ASP.NET-MVC-integration/204-dotnet-ASP.NET-MVC-integration.csproj
@@ -10,7 +10,7 @@
-
+
\ No newline at end of file
diff --git a/examples/301-discord-test-application/301-discord-test-application.csproj b/examples/301-discord-test-application/301-discord-test-application.csproj
index 1cb5af0ea..c46779eff 100644
--- a/examples/301-discord-test-application/301-discord-test-application.csproj
+++ b/examples/301-discord-test-application/301-discord-test-application.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/service/Core/ServiceCollectionExtensions.cs b/service/Core/ServiceCollectionExtensions.cs
index b827c6162..2228a7441 100644
--- a/service/Core/ServiceCollectionExtensions.cs
+++ b/service/Core/ServiceCollectionExtensions.cs
@@ -15,13 +15,17 @@ public static partial class ServiceCollectionExtensions
///
/// The to add the services to.
/// An optional action to configure the Kernel Memory builder.
+ /// Optional options passed to Build() call
/// A reference to this instance after the operation has completed.
- public static IServiceCollection AddKernelMemory(this IServiceCollection services, Action? setupAction = null)
+ public static IServiceCollection AddKernelMemory(
+ this IServiceCollection services,
+ Action? setupAction = null,
+ KernelMemoryBuilderBuildOptions? buildOptions = null)
{
var kernelMemoryBuilder = new KernelMemoryBuilder(services);
setupAction?.Invoke(kernelMemoryBuilder);
- var kernelMemory = kernelMemoryBuilder.Build();
+ var kernelMemory = kernelMemoryBuilder.Build(buildOptions);
services.AddSingleton(kernelMemory);
return services;
@@ -32,14 +36,18 @@ public static IServiceCollection AddKernelMemory(this IServiceCollection service
///
/// The to add the services to.
/// An optional action to configure the Kernel Memory builder.
+ /// Optional options passed to Build() call
/// A reference to this instance after the operation has completed.
- public static IServiceCollection AddKernelMemory(this IServiceCollection services, Action? setupAction = null)
+ public static IServiceCollection AddKernelMemory(
+ this IServiceCollection services,
+ Action? setupAction = null,
+ KernelMemoryBuilderBuildOptions? buildOptions = null)
where T : class, IKernelMemory
{
var kernelMemoryBuilder = new KernelMemoryBuilder(services);
setupAction?.Invoke(kernelMemoryBuilder);
- var kernelMemory = kernelMemoryBuilder.Build();
+ var kernelMemory = kernelMemoryBuilder.Build(buildOptions);
services.AddSingleton(kernelMemory);
services.AddSingleton(provider => provider.GetRequiredService());
diff --git a/service/tests/Core.UnitTests/KernelMemoryBuilderTest.cs b/service/tests/Core.UnitTests/KernelMemoryBuilderTest.cs
index a8bb12b62..6cc58e1cc 100644
--- a/service/tests/Core.UnitTests/KernelMemoryBuilderTest.cs
+++ b/service/tests/Core.UnitTests/KernelMemoryBuilderTest.cs
@@ -4,6 +4,7 @@
using Microsoft.KernelMemory;
using Microsoft.KernelMemory.AI;
using Microsoft.KernelMemory.DocumentStorage;
+using Microsoft.KernelMemory.DocumentStorage.DevTools;
using Microsoft.KernelMemory.MemoryStorage;
using Microsoft.KernelMemory.Pipeline;
using Microsoft.KernelMemory.Pipeline.Queue;
@@ -116,14 +117,48 @@ public void ItDetectsMissingEmbeddingGenerator()
[Trait("Category", "UnitTest")]
public void ItCanMixPersistentAndVolatileStorageIfNeeded()
{
+ // Arrange
KernelMemoryBuilderBuildOptions kmbOptions = new()
{
AllowMixingVolatileAndPersistentData = true
};
+ // Act - Assert no exception occurs
new KernelMemoryBuilder()
.WithOpenAIDefaults("key")
+ .WithSimpleFileStorage(SimpleFileStorageConfig.Volatile)
.WithPostgresMemoryDb("Host=localhost;Port=5432;Username=public;Password=;Database=public")
.Build(kmbOptions);
}
+
+ [Fact]
+ [Trait("Category", "UnitTest")]
+ public void ItCanMixPersistentAndVolatileStorageIfNeeded2()
+ {
+ // Arrange
+ KernelMemoryBuilderBuildOptions kmbOptions = new()
+ {
+ AllowMixingVolatileAndPersistentData = true
+ };
+
+ var serviceCollection1 = new ServiceCollection();
+ var serviceCollection2 = new ServiceCollection();
+
+ // Act - Assert no exception occurs
+ serviceCollection1.AddKernelMemory(builder =>
+ {
+ builder
+ .WithOpenAIDefaults("key")
+ .WithSimpleFileStorage(SimpleFileStorageConfig.Volatile)
+ .WithPostgresMemoryDb("Host=localhost;Port=5432;Username=public;Password=;Database=public");
+ }, kmbOptions);
+
+ serviceCollection2.AddKernelMemory(builder =>
+ {
+ builder
+ .WithOpenAIDefaults("key")
+ .WithSimpleFileStorage(SimpleFileStorageConfig.Volatile)
+ .WithPostgresMemoryDb("Host=localhost;Port=5432;Username=public;Password=;Database=public");
+ }, kmbOptions);
+ }
}