-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of store using Azure SQL/SQL Server with vector search.
- Loading branch information
1 parent
9b0dde5
commit 17b7696
Showing
12 changed files
with
1,018 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
dotnet/src/Connectors/Connectors.Memory.SqlServer/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
// This assembly is currently experimental. | ||
[assembly: Experimental("SKEXP0020")] |
29 changes: 29 additions & 0 deletions
29
dotnet/src/Connectors/Connectors.Memory.SqlServer/Connectors.Memory.SqlServer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<!-- THIS PROPERTY GROUP MUST COME FIRST --> | ||
<AssemblyName>Microsoft.SemanticKernel.Connectors.SqlServer</AssemblyName> | ||
<RootNamespace>$(AssemblyName)</RootNamespace> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<VersionSuffix>alpha</VersionSuffix> | ||
</PropertyGroup> | ||
|
||
<!-- IMPORT NUGET PACKAGE SHARED PROPERTIES --> | ||
<Import Project="$(RepoRoot)/dotnet/nuget/nuget-package.props" /> | ||
<Import Project="$(RepoRoot)/dotnet/src/InternalUtilities/src/InternalUtilities.props" /> | ||
|
||
<PropertyGroup> | ||
<!-- NuGet Package Settings --> | ||
<Title>Semantic Kernel - SQL Server Connector</Title> | ||
<Description>SQL Server connector for Semantic Kernel plugins and semantic memory</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Data.SqlClient" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\SemanticKernel.Core\SemanticKernel.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
83 changes: 83 additions & 0 deletions
83
dotnet/src/Connectors/Connectors.Memory.SqlServer/ISqlServerClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.SemanticKernel.Connectors.SqlServer; | ||
|
||
/// <summary> | ||
/// Interface for client managing SQL Server or Azure SQL database operations. | ||
/// </summary> | ||
internal interface ISqlServerClient | ||
{ | ||
/// <summary> | ||
/// Create a table. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
Task CreateTableAsync(string tableName, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Get all tables. | ||
/// </summary> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>A group of tables.</returns> | ||
IAsyncEnumerable<string> GetTablesAsync(CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Check if a table exists. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
Task<bool> DoesTableExistsAsync(string tableName, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Delete a table. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
Task DeleteTableAsync(string tableName, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Upsert entry into a table. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="key">The key of the entry to upsert.</param> | ||
/// <param name="metadata">The metadata of the entry.</param> | ||
/// <param name="embedding">The embedding of the entry.</param> | ||
/// <param name="timestamp">The timestamp of the entry.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
Task UpsertAsync(string tableName, string key, string metadata, ReadOnlyMemory<float> embedding, DateTimeOffset? timestamp, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Read multiple entries by their keys. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="keys">The keys of the entries to read.</param> | ||
/// <param name="withEmbeddings">If true, the embeddings will be returned in the entries.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>An asynchronous stream of <see cref="SqlServerMemoryEntry"/> objects that match the given keys.</returns> | ||
IAsyncEnumerable<SqlServerMemoryEntry> ReadBatchAsync(string tableName, IEnumerable<string> keys, bool withEmbeddings = false, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Delete multiple entries by their key. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="keys">The keys of the entries to delete.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
Task DeleteBatchAsync(string tableName, IEnumerable<string> keys, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets the nearest matches to the embedding. | ||
/// </summary> | ||
/// <param name="tableName">The name assigned to a table of entries.</param> | ||
/// <param name="embedding">The embedding to compare the table's embeddings with.</param> | ||
/// <param name="limit">The maximum number of similarity results to return.</param> | ||
/// <param name="minRelevanceScore">The minimum relevance threshold for returned results.</param> | ||
/// <param name="withEmbeddings">If true, the embeddings will be returned in the entries.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>An asynchronous stream of <see cref="SqlServerMemoryEntry"/> objects that the nearest matches to the embedding.</returns> | ||
IAsyncEnumerable<(SqlServerMemoryEntry, double)> GetNearestMatchesAsync(string tableName, ReadOnlyMemory<float> embedding, int limit, double minRelevanceScore = 0, bool withEmbeddings = false, CancellationToken cancellationToken = default); | ||
} |
Oops, something went wrong.