-
Couldn't load subscription status.
- Fork 394
Open
Labels
Description
Context / Scenario
I followed https://github.com/microsoft/kernel-memory/blob/bd8d34e67dcd2b52acb408661d58b648453efbd3/examples/303-dotnet-aspire/Program.cs and rewrote it to use the Aspire hosting package for Qdrant.
It throws an exception, related to the issue in #977.
What happened?
The kernel-memory/service container crashes during startup with this exception:
Microsoft.KernelMemory.ConfigurationException: Using a persistent memory store (QdrantMemory) with a volatile document store (SimpleFileStorage Volatile) will lead to duplicate memory records over multiple executions. Set up Kernel Memory to use a persistent document store like Azure Blobs, AWS S3, SimpleFileStorage on disk, etc. Otherwise, use KernelMemoryBuilderBuildOptions.AllowMixingVolatileAndPersistentData to suppress this exception when invoking kernelMemoryBuilder.Build(<options here>).
My code:
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.KernelMemory;
const string KMDockerImage = "kernelmemory/service";
AzureOpenAIConfig s_azureOpenAIEmbeddingConfig = new();
AzureOpenAIConfig s_azureOpenAITextConfig = new();
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();
// Use the 'GetSection' method and 'Bind' to populate the configuration objects
configuration.GetSection("KernelMemory:Services:AzureOpenAIEmbedding").Bind(s_azureOpenAIEmbeddingConfig);
configuration.GetSection("KernelMemory:Services:AzureOpenAIText").Bind(s_azureOpenAITextConfig);
var builder = DistributedApplication.CreateBuilder(args);
SetupKernelMemory(s_azureOpenAIEmbeddingConfig, s_azureOpenAITextConfig, "latest", builder);
builder.Build().Run();
static void SetupKernelMemory(AzureOpenAIConfig s_azureOpenAIEmbeddingConfig, AzureOpenAIConfig s_azureOpenAITextConfig, string dockerTag, IDistributedApplicationBuilder builder)
{
var qdrant = builder.AddQdrant("qdrant")
.WithLifetime(ContainerLifetime.Persistent);
// Find Qdrant endpoint and pass the value to KM below
var qdrantEndpoint = qdrant.GetEndpoint("http");
var qdrantApiKey = qdrant.Resource.ApiKeyParameter.Value;
builder.AddContainer("kernel-memory", KMDockerImage, tag: dockerTag)
.WithHttpEndpoint(targetPort: 9001)
// Wait for Qdrant to be ready
.WaitFor(qdrant)
// Global KM settings
.WithEnvironment("KernelMemory__TextGeneratorType", "AzureOpenAIText")
.WithEnvironment("KernelMemory__DataIngestion__EmbeddingGeneratorTypes__0", "AzureOpenAIEmbedding")
.WithEnvironment("KernelMemory__DataIngestion__MemoryDbTypes__0", "Qdrant")
.WithEnvironment("KernelMemory__Retrieval__EmbeddingGeneratorType", "AzureOpenAIEmbedding")
.WithEnvironment("KernelMemory__Retrieval__MemoryDbType", "Qdrant")
// Qdrant settings
.WithEnvironment("KernelMemory__Services__Qdrant__Endpoint", qdrantEndpoint)
.WithEnvironment("KernelMemory__Services__Qdrant__APIKey", qdrantApiKey)
// Azure OpenAI settings - Text generation
.WithEnvironment("KernelMemory__Services__AzureOpenAIText__Auth", s_azureOpenAITextConfig.Auth.ToString("G"))
.WithEnvironment("KernelMemory__Services__AzureOpenAIText__APIKey", s_azureOpenAITextConfig.APIKey)
.WithEnvironment("KernelMemory__Services__AzureOpenAIText__Endpoint", s_azureOpenAITextConfig.Endpoint)
.WithEnvironment("KernelMemory__Services__AzureOpenAIText__Deployment", s_azureOpenAITextConfig.Deployment)
// Azure OpenAI settings - Embeddings
.WithEnvironment("KernelMemory__Services__AzureOpenAIEmbedding__Auth", s_azureOpenAIEmbeddingConfig.Auth.ToString("G"))
.WithEnvironment("KernelMemory__Services__AzureOpenAIEmbedding__APIKey", s_azureOpenAIEmbeddingConfig.APIKey)
.WithEnvironment("KernelMemory__Services__AzureOpenAIEmbedding__Endpoint", s_azureOpenAIEmbeddingConfig.Endpoint)
.WithEnvironment("KernelMemory__Services__AzureOpenAIEmbedding__Deployment", s_azureOpenAIEmbeddingConfig.Deployment)
.PublishAsContainer();
}Importance
edge case
Platform, Language, Versions
- Aspire.Net 9.3.0
- Aspire.Hosting.Qdrant 9.3.0
kernel-memory/service(Digestsha256:96ac704f74097979f7db3cdbfb4c5c6d579748c7201e3b7563728e1a0004d603)
Relevant log output
Unhandled exception. Microsoft.KernelMemory.ConfigurationException: Using a persistent memory store (QdrantMemory) with a volatile document store (SimpleFileStorage Volatile) will lead to duplicate memory records over multiple executions. Set up Kernel Memory to use a persistent document store like Azure Blobs, AWS S3, SimpleFileStorage on disk, etc. Otherwise, use KernelMemoryBuilderBuildOptions.AllowMixingVolatileAndPersistentData to suppress this exception when invoking kernelMemoryBuilder.Build(<options here>).
at Microsoft.KernelMemory.KernelMemoryBuilder.CheckStoragePersistence(KernelMemoryBuilderBuildOptions options, ServiceProvider serviceProvider) in /src/service/Core/KernelMemoryBuilder.cs:line 326
at Microsoft.KernelMemory.KernelMemoryBuilder.BuildAsyncClient(KernelMemoryBuilderBuildOptions options) in /src/service/Core/KernelMemoryBuilder.cs:line 287
at Microsoft.KernelMemory.KernelMemoryBuilder.Build(KernelMemoryBuilderBuildOptions options) in /src/service/Core/KernelMemoryBuilder.cs:line 129
at Microsoft.KernelMemory.WebApplicationBuilderExtensions.AddKernelMemory(WebApplicationBuilder appBuilder, Action`1 configureMemoryBuilder, Action`1 configureMemory, Action`1 configureServices, KernelMemoryBuilderBuildOptions buildOptions) in /src/service/Service.AspNetCore/WebApplicationBuilderExtensions.cs:line 40
at Microsoft.KernelMemory.Service.Program.Main(String[] args) in /src/service/Service/Program.cs:line 98