microsoft / kernel-memory

RAG architecture: index and query any data using LLM and natural language, track sources, show citations, asynchronous memory patterns.

Home Page:https://microsoft.github.io/kernel-memory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Running as Serverless but with Data Persistence

HazyFish opened this issue · comments

My use case does not require a Web API layer or queue for data ingestion, but I need data persisted in a database. Currently, if we run it in Serverless mode, everything is volatile. If we run it in service mode, we need all the components which might not be necessary for all use cases. Could we refactor the code to make it more modular and support some middle grounds between the 2?

hi @HazyFish the volatile mode is only the default configuration, and you can easily change that. In serverless mode, there's 2 components to setup: file storage and memory storage.

(In Service mode you would also configure a persistent orchestration queue using Azure Queues or RabbitMQ).

Here's a few examples:

var memory = new KernelMemoryBuilder()
    .WithOpenAI(openAICfg)
    .WithAzureBlobsStorage(azureBlobsConfig) // file storage in the cloud, for Prod use cases
    .WithAzureAISearch(azureSearchConfig)  // memory storage in the cloud, for Prod use cases
    .Build<MemoryServerless>();
var memory = new KernelMemoryBuilder()
    .WithOpenAI(openAICfg)
    .WithSimpleFileStorage(new SimpleFileStorageConfig { StorageType = FileSystemTypes.Disk }) // local file storage
    .WithQdrantMemoryDb(qdrantConfig) // memory storage on Qdrant, both local or in the cloud
    .Build<MemoryServerless>();
var memory = new KernelMemoryBuilder()
    .WithOpenAI(openAICfg)
    .WithSimpleFileStorage(new SimpleFileStorageConfig { StorageType = FileSystemTypes.Disk }) // local file storage
    .WithSimpleVectorDb(new SimpleVectorDbConfig { StorageType = FileSystemTypes.Disk }) // memory storage, designed for tests/dev, doesn't scale to millions of memories
    .Build<MemoryServerless>();

There are also other options, e.g. type .With... to see IntelliSense suggestions.

Thank you so much for the prompt response!!! I hope this is added to the README.md for more clarity. Should I close the issue now?

@HazyFish I'll close the issue -- we're updating the docs and we'll make this easier to find, thanks for the feedback!

You can take a sneak peak at https://microsoft.github.io/kernel-memory to see the work in progress :-)