Microsoft.KernelMemory.MemoryDb.SQLServer
0.92.241112.1
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.KernelMemory.MemoryDb.SQLServer --version 0.92.241112.1
NuGet\Install-Package Microsoft.KernelMemory.MemoryDb.SQLServer -Version 0.92.241112.1
<PackageReference Include="Microsoft.KernelMemory.MemoryDb.SQLServer" Version="0.92.241112.1" />
paket add Microsoft.KernelMemory.MemoryDb.SQLServer --version 0.92.241112.1
#r "nuget: Microsoft.KernelMemory.MemoryDb.SQLServer, 0.92.241112.1"
// Install Microsoft.KernelMemory.MemoryDb.SQLServer as a Cake Addin #addin nuget:?package=Microsoft.KernelMemory.MemoryDb.SQLServer&version=0.92.241112.1 // Install Microsoft.KernelMemory.MemoryDb.SQLServer as a Cake Tool #tool nuget:?package=Microsoft.KernelMemory.MemoryDb.SQLServer&version=0.92.241112.1
Kernel Memory with Microsoft SQL Server
This folder contains tests for the MS SQL Server extension for Kernel Memory.
Please note that the connector should not be confused with a NL2SQL feature, e.g. the ability to query the content of a pre-existing SQL server. If you are looking for a solution that allows to import content from a SQL server and make it searchable please see How to index data from Azure SQL in Azure AI Search
Configuration
Configuration (appsettings.json):
// ...
"SqlServer": {
"ConnectionString": "...",
}
// ...
Setup with Kernel Memory Builder / Dependency Injection
Method 1, simple applications:
var sqlServerConfig = cfg.GetSection("Services:SqlServer").Get<SqlServerConfig>()!;
var memory = new KernelMemoryBuilder()
.WithSqlServerMemoryDb(sqlServerConfig)
// .WithOpenAI(openAiConfig)
// .WithAzureOpenAITextGeneration(azureOpenAITextConfiguration)
// .WithAzureOpenAITextEmbeddingGeneration(azureOpenAIEmbeddingConfiguration)
// .Build();
Method 2, injecting memory into an ASP.NET app:
builder.Services.AddSingleton<IKernelMemory>(sp =>
{
KernelMemoryBuilder kernelMemoryBuilder = new()
.WithSqlServerMemoryDb(builder.Configuration.GetConnectionString("DefaultConnection"))
//...
return kernelMemoryBuilder.Build<MemoryServerless>();
});
KM Service setup
To run Kernel Memory service with SQL Server backend:
- clone KM repository
- add
KernelMemory.MemoryStorage.SqlServer
nuget to Service.csproj - edit the part using
KernelMemoryBuilder
adding the same.WithSqlServerMemoryDb(...)
call mentioned in the previous paragraph, e.g.IKernelMemory memory = new KernelMemoryBuilder(appBuilder.Services) .FromAppSettings() .WithSqlServerMemoryDb(...) .Build();
Local tests with Docker
You can test the connector locally with Docker:
docker pull mcr.microsoft.com/mssql/server:2022-latest
docker run -it -p 1433:1433 --rm -e "MSSQL_SA_PASSWORD=00_CHANGE_ME_00" -e "ACCEPT_EULA=Y" \
mcr.microsoft.com/mssql/server:2022-latest
...using the following connection string:
Server=tcp:127.0.0.1,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password=00_CHANGE_ME_00;MultipleActiveResultSets=False;TrustServerCertificate=True;Connection Timeout=30;
For more information about the SQL Server Linux container:
- https://learn.microsoft.com/sql/linux/quickstart-install-connect-docker
- https://devblogs.microsoft.com/azure-sql/development-with-sql-in-containers-on-macos/
Batch Upsert Feature
The SQL Server Memory DB now supports batching upsert operations, enhancing performance for bulk data operations. This feature allows for efficient insertion or updating of multiple records in a single operation.
Using Batch Upsert
To use the batch upsert feature, you can utilize the BatchUpsertAsync
method. This method accepts an index name and an enumerable of MemoryRecord
objects, performing upsert operations for all provided records in a batch.
Example:
var records = new List<MemoryRecord>
{
new MemoryRecord("id1", new Dictionary<string, object> { { "key", "value1" } }),
new MemoryRecord("id2", new Dictionary<string, object> { { "key", "value2" } })
};
await memory.BatchUpsertAsync("yourIndexName", records);
This method efficiently handles the insertion or updating of records, significantly improving performance for operations involving large datasets.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.KernelMemory.Abstractions (>= 0.92.241112.1)
- System.Runtime.Caching (>= 8.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Microsoft.KernelMemory.MemoryDb.SQLServer:
Package | Downloads |
---|---|
Microsoft.KernelMemory
The package contains all the core logic and extensions of Kernel Memory, to index and query any data and documents, using LLM and natural language, tracking sources and showing citations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.94.241201.1 | 288 | 12/1/2024 |
0.93.241118.1 | 1,275 | 11/19/2024 |
0.92.241112.1 | 675 | 11/12/2024 |
0.91.241101.1 | 983 | 11/1/2024 |
0.91.241031.1 | 133 | 10/31/2024 |
0.90.241021.1 | 2,498 | 10/22/2024 |
0.90.241020.3 | 118 | 10/20/2024 |
0.80.241017.2 | 2,523 | 10/17/2024 |
0.79.241014.2 | 1,945 | 10/14/2024 |
0.79.241014.1 | 195 | 10/14/2024 |
0.78.241007.1 | 3,531 | 10/8/2024 |
0.78.241005.1 | 503 | 10/6/2024 |
0.77.241004.1 | 364 | 10/5/2024 |
0.76.240930.3 | 5,462 | 9/30/2024 |
0.75.240924.1 | 7,688 | 9/24/2024 |
0.74.240919.1 | 3,189 | 9/19/2024 |
0.73.240906.1 | 23,227 | 9/7/2024 |
0.72.240904.1 | 2,868 | 9/5/2024 |
0.71.240820.1 | 12,862 | 8/21/2024 |
0.70.240803.1 | 22,821 | 8/3/2024 |
0.69.240727.1 | 8,972 | 7/27/2024 |
0.68.240722.1 | 3,058 | 7/22/2024 |
0.68.240716.1 | 1,998 | 7/16/2024 |
0.67.240712.1 | 1,758 | 7/12/2024 |
0.66.240709.1 | 5,587 | 7/9/2024 |
0.65.240620.1 | 32,385 | 6/21/2024 |
0.64.240619.1 | 783 | 6/20/2024 |
0.63.240618.1 | 2,896 | 6/18/2024 |
0.62.240605.1 | 22,581 | 6/5/2024 |
0.62.240604.1 | 564 | 6/4/2024 |
0.61.240524.1 | 10,042 | 5/24/2024 |
0.61.240519.2 | 10,051 | 5/19/2024 |
0.60.240517.1 | 213 | 5/18/2024 |
0.51.240513.2 | 7,213 | 5/13/2024 |