Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Added implementation of SQLite connector for new memory design #9164

Merged
merged 128 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
d7287bb
.Net: ADR for Text Search Abstractions (#8307)
markwallace-microsoft Aug 22, 2024
590745f
.Net: Add TextSearchExtension methods to create KernelPlugins and Ker…
markwallace-microsoft Aug 27, 2024
3c09d91
.Net: Update Bing Search to new Text Search Design (#8343)
markwallace-microsoft Aug 29, 2024
187afca
Merge branch 'main' into feature-vector-search
markwallace-microsoft Aug 29, 2024
16f4fa1
.Net: Update Google Search to new Text Search Design (#8394)
markwallace-microsoft Aug 29, 2024
5af6540
.Net: Add text search concepts demonstrating RAG and Function Calling…
markwallace-microsoft Aug 30, 2024
6d13254
Merge branch 'main' into feature-vector-search
markwallace-microsoft Aug 30, 2024
f806fc2
.Net: Simplify how additional text search filter parameters are speci…
markwallace-microsoft Sep 2, 2024
890c0f8
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 2, 2024
cfbac04
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 3, 2024
b96d607
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 3, 2024
4b8406e
.Net: Add Vector Search ADR document and abstractions (#8494)
westey-m Sep 4, 2024
d02005a
.Net: Add support for advanced search keywords (#8489)
markwallace-microsoft Sep 4, 2024
ac540db
.Net: Use interfaces for mapper abstractions (#8424)
markwallace-microsoft Sep 4, 2024
d745d57
.Net: Add vector search implementation for azure ai search (#8507)
westey-m Sep 5, 2024
7836721
.Net: Add qdrant vector search implementation. (#8508)
westey-m Sep 5, 2024
ec10424
.Net: Add Redis vector search implementation (#8510)
westey-m Sep 5, 2024
d43c5ff
.Net: Unify text and vector search and move all to data namespace. (#…
westey-m Sep 6, 2024
70a98ee
.Net: Add volatile vector search and enforcing collection type. (#8546)
westey-m Sep 6, 2024
ffaa93f
Update adr document with filter changes. (#8590)
westey-m Sep 9, 2024
639694b
Resolve merge conflicts
markwallace-microsoft Sep 11, 2024
c1cd203
Fix formatting
markwallace-microsoft Sep 11, 2024
7bdf519
Merge branch 'main' into feature-vector-search
westey-m Sep 12, 2024
6b92a18
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 13, 2024
1fc7e91
.Net: Switch to using interfaces for search instead of query objects.…
westey-m Sep 13, 2024
9c8e438
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 13, 2024
031a653
Merge branch 'main' into feature-vector-search
westey-m Sep 17, 2024
971afd6
.Net: Suppress moq warning after taking package updates. (#8838)
westey-m Sep 17, 2024
bf34a51
.Net: Basic implementation of ITextSearch for an IVectorStore impleme…
markwallace-microsoft Sep 17, 2024
434498a
.Net: Add float64 support for redis vector search. (#8847)
westey-m Sep 17, 2024
092a9ac
Merge branch 'main' into feature-vector-search
dmytrostruk Sep 18, 2024
f35d051
.Net: Enhance volatile memory connector to allow collection to be ser…
markwallace-microsoft Sep 18, 2024
8dc7dc3
.Net: Added vector search implementation for Azure CosmosDB for Mongo…
dmytrostruk Sep 18, 2024
fa461ce
.Net: Vector Search Bug fixes (#8890)
westey-m Sep 18, 2024
be531dd
.Net: [Feature branch] Added support for Filter and Offset parameters…
dmytrostruk Sep 19, 2024
36aa3f2
.Net: Vector search sample: Multi Vector and Paging (#8920)
westey-m Sep 20, 2024
8fa1e8e
.Net: Adding a multi-store vector search sample. (#8909)
westey-m Sep 20, 2024
b5c649f
.Net: [Feature Branch] Added vector search implementation for Azure C…
dmytrostruk Sep 20, 2024
952d679
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 20, 2024
6c4aa5d
.Net: Add VectorStoreTextSearch concepts and unit tests (#8891)
markwallace-microsoft Sep 23, 2024
cb00332
Merge branch 'main' into feature-vector-search
westey-m Sep 23, 2024
21f8a27
.Net: [Feature Branch] Added vector search implementation for Weaviat…
dmytrostruk Sep 23, 2024
d6b6019
.Net: Add filtering support for VectoreStoreTextSearch (#8947)
markwallace-microsoft Sep 24, 2024
1c35c01
Merge branch 'main' into feature-vector-search
markwallace-microsoft Sep 24, 2024
6d041b3
.Net: Adding generic data type support to the volatile vector store. …
westey-m Sep 24, 2024
16f787e
.Net: Rename a number of properties as agreed and remove dangerous de…
westey-m Sep 25, 2024
12a85d5
Merge branch 'main' into feature-vector-search
dmytrostruk Sep 26, 2024
66d608c
.Net: Add delegates for the string and result mappers (#9000)
markwallace-microsoft Sep 26, 2024
d08eef3
.Net: Integration tests for Bing and Google text search (#8991)
markwallace-microsoft Sep 27, 2024
21e37a0
.Net: Add DI registration helpers for collections and search (#9007)
westey-m Sep 27, 2024
a6dc6b3
Merge branch 'main' into feature-vector-search
dmytrostruk Sep 30, 2024
2758ff7
Fix after merge
dmytrostruk Sep 30, 2024
da7291b
Implemented database manipulation methods
dmytrostruk Oct 1, 2024
667533e
Merge branch 'main' into feature-vector-search
markwallace-microsoft Oct 1, 2024
7975fed
Merge branch 'main' into feature-vector-search
markwallace-microsoft Oct 1, 2024
6931b79
Merge branch 'main' into feature-vector-search
markwallace-microsoft Oct 1, 2024
5bce499
.Net: Fix issues after vector split merge. (#9050)
westey-m Oct 1, 2024
1046bd3
Merge branch 'feature-vector-search' into sqlite-connector
dmytrostruk Oct 1, 2024
467191e
.Net: Support DI for Text Search Services (#9026)
markwallace-microsoft Oct 1, 2024
a608659
Fixed compilation errors after merge
dmytrostruk Oct 1, 2024
136fc0f
Added creation of virtual table for vectors
dmytrostruk Oct 1, 2024
d6ec1ee
Added deletion of virtual table for vectors
dmytrostruk Oct 1, 2024
2b94b08
.Net: Adapt In-Memory Connector to new Text Search Design (#9046)
markwallace-microsoft Oct 2, 2024
7710e36
Merge branch 'main' into feature-vector-search
markwallace-microsoft Oct 2, 2024
e2e22b6
.Net: Vector search recordreader manual merge (#9059)
westey-m Oct 2, 2024
6b05639
Implemented default mapper
dmytrostruk Oct 2, 2024
c4f3c66
Merge branch 'feature-vector-search' into sqlite-connector
dmytrostruk Oct 2, 2024
3b02888
Implemented Get and Upsert operations
dmytrostruk Oct 3, 2024
d8eb4b5
.Net: Adapt Azure AI Search Connector to new Text Search Design (#9061)
markwallace-microsoft Oct 3, 2024
d98e218
Implemented Delete record operations. Fixed batch operations.
dmytrostruk Oct 3, 2024
098ba75
Exposed virtual table name configuration
dmytrostruk Oct 3, 2024
e668013
Added test for string keys
dmytrostruk Oct 3, 2024
0179733
Added distance function mapping
dmytrostruk Oct 3, 2024
cc8fe45
.Net: Add response container type for vector search results. (#9082)
westey-m Oct 4, 2024
fba0aba
.Net: Use AsynEnumerable search interface for azure ai search. (#9090)
westey-m Oct 4, 2024
c198b09
Vector search and code refactoring
dmytrostruk Oct 4, 2024
d09e70f
Added offset logic
dmytrostruk Oct 5, 2024
03b89fe
Added filter usage
dmytrostruk Oct 5, 2024
69b9fc4
.Net: Update Qdrant Memory Connector to new Text Search Design (#9076)
markwallace-microsoft Oct 7, 2024
6d32d34
.Net: Add attributes to add to a model which can be converted to a Te…
markwallace-microsoft Oct 7, 2024
805febe
.Net: Change signature of the TextSearchResult constructor (#9153)
markwallace-microsoft Oct 8, 2024
add4461
Merge branch 'feature-vector-search' into sqlite-connector
dmytrostruk Oct 8, 2024
ea335bc
Merge from feature branch
dmytrostruk Oct 8, 2024
22e24a5
Merge branch 'main' into feature-vector-search
dmytrostruk Oct 8, 2024
db95435
Merge branch 'feature-vector-search' into sqlite-connector
dmytrostruk Oct 8, 2024
2d88cfb
Added support for generic data model
dmytrostruk Oct 8, 2024
bb2b457
Added vector store class
dmytrostruk Oct 9, 2024
806829d
Added extension methods
dmytrostruk Oct 9, 2024
4625afb
Small fix
dmytrostruk Oct 9, 2024
46ec215
Small fix
dmytrostruk Oct 9, 2024
b85b0e7
Fixed warnings
dmytrostruk Oct 9, 2024
a8af704
Fixed warning
dmytrostruk Oct 9, 2024
f29e110
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 9, 2024
0dec618
Fix after merge
dmytrostruk Oct 9, 2024
59e9bba
Fixed usings
dmytrostruk Oct 9, 2024
21cf1ac
Added unit tests
dmytrostruk Oct 9, 2024
4687d06
More unit tests
dmytrostruk Oct 9, 2024
52c8a4c
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 10, 2024
7da8523
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 11, 2024
22c9491
Fixes after merge
dmytrostruk Oct 11, 2024
270e9e1
Moved Sqlite unit test project
dmytrostruk Oct 11, 2024
f7cbaf2
Addressed PR feedback
dmytrostruk Oct 11, 2024
9094eaa
Added more comments
dmytrostruk Oct 11, 2024
aa4b4b6
More improvements and fixes
dmytrostruk Oct 11, 2024
79dac79
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 11, 2024
77fe3c2
Updated mapping and fixed tests
dmytrostruk Oct 14, 2024
4ecf78c
Fixed usings
dmytrostruk Oct 14, 2024
a34fc23
Added unit tests for command builder
dmytrostruk Oct 14, 2024
ecf6de9
Added unit tests for record collection class
dmytrostruk Oct 14, 2024
43900fd
Added integration test to get existing record
dmytrostruk Oct 14, 2024
7453e21
Fixed warnings
dmytrostruk Oct 14, 2024
3a797fb
Updated extension methods
dmytrostruk Oct 14, 2024
1b75ccd
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 15, 2024
44e366f
Fixes based on merge from main
dmytrostruk Oct 15, 2024
cbd2902
Added more tests
dmytrostruk Oct 16, 2024
5048f9f
Small fix
dmytrostruk Oct 16, 2024
4458478
Small refactoring
dmytrostruk Oct 16, 2024
c4df0c6
Addressed PR feedback
dmytrostruk Oct 16, 2024
c55e350
Added more tests for collection class
dmytrostruk Oct 16, 2024
d8e72b3
Added unit tests for default record mapper
dmytrostruk Oct 16, 2024
53e3c5a
Added more unit tests
dmytrostruk Oct 16, 2024
9884082
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 16, 2024
e10ccf7
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 17, 2024
a335a61
Addressed PR feedback
dmytrostruk Oct 17, 2024
6510a66
Updated SQLite connector package version suffix
dmytrostruk Oct 17, 2024
c79b8c6
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 17, 2024
5b5399e
Removed kernel builder extensions
dmytrostruk Oct 17, 2024
033ca59
Merge branch 'main' into sqlite-connector
dmytrostruk Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions dotnet/SK-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Process.UnitTests", "src\Ex
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStartedWithProcesses", "samples\GettingStartedWithProcesses\GettingStartedWithProcesses.csproj", "{C057ACDF-DDD8-496B-BAF9-1C6E4E1248D7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connectors.Sqlite.UnitTests", "src\Connectors\Connectors.Sqlite.UnitTests\Connectors.Sqlite.UnitTests.csproj", "{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connectors.Sqlite.UnitTests", "src\Connectors\Connectors.Sqlite.UnitTests\Connectors.Sqlite.UnitTests.csproj", "{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VectorData.Abstractions", "src\Connectors\VectorData.Abstractions\VectorData.Abstractions.csproj", "{CF09AE39-67BA-4FE0-A0CD-A49BED956311}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connectors.Memory.InMemory", "src\Connectors\Connectors.Memory.InMemory\Connectors.Memory.InMemory.csproj", "{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MemoryUnitTests", "MemoryUnitTests", "{5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connectors.InMemory.UnitTests", "src\Connectors\Connectors.InMemory.UnitTests\Connectors.InMemory.UnitTests.csproj", "{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GettingStartedWithTextSearch", "samples\GettingStartedWithTextSearch\GettingStartedWithTextSearch.csproj", "{16AFA226-E417-490D-9311-9F2099A1EEC8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VectorStoreRAG", "samples\Demos\VectorStoreRAG\VectorStoreRAG.csproj", "{28DFAF27-8FF3-4373-AAA4-2A6969C86246}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -934,6 +946,36 @@ Global
{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E}.Publish|Any CPU.Build.0 = Debug|Any CPU
{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E}.Release|Any CPU.Build.0 = Release|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Publish|Any CPU.Build.0 = Publish|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF09AE39-67BA-4FE0-A0CD-A49BED956311}.Release|Any CPU.Build.0 = Release|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Publish|Any CPU.ActiveCfg = Publish|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Publish|Any CPU.Build.0 = Publish|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7}.Release|Any CPU.Build.0 = Release|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Publish|Any CPU.Build.0 = Debug|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42}.Release|Any CPU.Build.0 = Release|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Publish|Any CPU.Build.0 = Debug|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16AFA226-E417-490D-9311-9F2099A1EEC8}.Release|Any CPU.Build.0 = Release|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Publish|Any CPU.Build.0 = Debug|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28DFAF27-8FF3-4373-AAA4-2A6969C86246}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1062,7 +1104,13 @@ Global
{27AF60D6-86F5-4591-A700-4F8C93F41B11} = {0D8C6358-5DAA-4EA6-A924-C268A9A21BC9}
{21A32285-8443-4A75-B2E8-27E6090EC562} = {0D8C6358-5DAA-4EA6-A924-C268A9A21BC9}
{C057ACDF-DDD8-496B-BAF9-1C6E4E1248D7} = {FA3720F1-C99A-49B2-9577-A940257098BF}
{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E} = {0247C2C9-86C3-45BA-8873-28B0948EDC0C}
{0846F178-7EC3-4FE6-AC5C-7146E9FD9A3E} = {5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}
{CF09AE39-67BA-4FE0-A0CD-A49BED956311} = {24503383-A8C4-4255-9998-28D70FE8E99A}
{265B8B6E-B9C4-44C7-BE96-59750F9A1DC7} = {24503383-A8C4-4255-9998-28D70FE8E99A}
{5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89} = {0247C2C9-86C3-45BA-8873-28B0948EDC0C}
{A0B91C05-B3A6-436B-8F49-3427EC1CFC42} = {5A7028A7-4DDF-4E4F-84A9-37CE8F8D7E89}
{16AFA226-E417-490D-9311-9F2099A1EEC8} = {FA3720F1-C99A-49B2-9577-A940257098BF}
{28DFAF27-8FF3-4373-AAA4-2A6969C86246} = {5D4C0700-BBB5-418F-A7B2-F392B9A18263}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

internal abstract record SqliteWhereCondition(string Operand, List<object> Values, string? TableName = null)
internal abstract class SqliteWhereCondition(string operand, List<object> values)
{
public string Operand { get; set; } = operand;

public List<object> Values { get; set; } = values;

public string? TableName { get; set; }

public abstract string BuildQuery(List<string> parameterNames);

protected string GetOperand() => !string.IsNullOrWhiteSpace(this.TableName) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

internal sealed record SqliteWhereEqualsCondition(string Operand, object Value, string? TableName = null)
: SqliteWhereCondition(Operand, [Value], TableName)
internal sealed class SqliteWhereEqualsCondition(string operand, object value)
: SqliteWhereCondition(operand, [value])
{
public override string BuildQuery(List<string> parameterNames)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

internal sealed record SqliteWhereInCondition(string Operand, List<object> Values, string? TableName = null)
: SqliteWhereCondition(Operand, Values, TableName)
internal sealed class SqliteWhereInCondition(string operand, List<object> values)
: SqliteWhereCondition(operand, values)
{
public override string BuildQuery(List<string> parameterNames)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

internal sealed record SqliteWhereMatchCondition(string Operand, object Value, string? TableName = null)
: SqliteWhereCondition(Operand, [Value], TableName)
internal sealed class SqliteWhereMatchCondition(string operand, object value)
: SqliteWhereCondition(operand, [value])
{
public override string BuildQuery(List<string> parameterNames)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Data.Common;
using Microsoft.SemanticKernel.Data;
using Microsoft.Extensions.VectorData;

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

Expand All @@ -23,6 +23,5 @@ IVectorStoreRecordCollection<TKey, TRecord> CreateVectorStoreRecordCollection<TK
DbConnection connection,
string name,
VectorStoreRecordDefinition? vectorStoreRecordDefinition)
where TKey : notnull
where TRecord : class;
where TKey : notnull;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ internal static class SqliteConstants
typeof(decimal),
typeof(decimal?),
typeof(byte[]),
typeof(DateTime),
typeof(DateTime?)
];

/// <summary>A <see cref="HashSet{T}"/> of types that vector properties on the provided model may have.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using System;
using System.Collections.Generic;
using Microsoft.SemanticKernel.Data;
using Microsoft.Extensions.VectorData;

namespace Microsoft.SemanticKernel.Connectors.Sqlite;

Expand All @@ -25,6 +25,10 @@ public SqliteGenericDataModelMapper(VectorStoreRecordPropertyReader propertyRead
Verify.NotNull(propertyReader);

this._propertyReader = propertyReader;

// Validate property types.
this._propertyReader.VerifyDataProperties(SqliteConstants.SupportedDataTypes, supportEnumerable: false);
this._propertyReader.VerifyVectorProperties(SqliteConstants.SupportedVectorTypes);
}

#region Implementation of IVectorStoreRecordMapper<VectorStoreGenericDataModel<string>, Dictionary<string, object?>>
Expand Down Expand Up @@ -73,7 +77,7 @@ public VectorStoreGenericDataModel<string> MapFromStorageToDataModel(Dictionary<
{
if (dataModel.Data.TryGetValue(property.DataModelPropertyName, out var dataValue))
{
properties.Add(this._propertyReader.StoragePropertyNamesMap[property.DataModelPropertyName], dataValue);
properties.Add(this._propertyReader.GetStoragePropertyName(property.DataModelPropertyName), dataValue);
}
}
}
Expand All @@ -90,10 +94,10 @@ public VectorStoreGenericDataModel<string> MapFromStorageToDataModel(Dictionary<
if (vectorValue is not null)
{
var vector = (ReadOnlyMemory<float>)vectorValue;
result = SqliteVectorStoreRecordPropertyMapping.MapVector(vector);
result = SqliteVectorStoreRecordPropertyMapping.MapVectorForStorageModel(vector);
}

properties.Add(this._propertyReader.StoragePropertyNamesMap[property.DataModelPropertyName], result);
properties.Add(this._propertyReader.GetStoragePropertyName(property.DataModelPropertyName), result);
}
}
}
Expand Down Expand Up @@ -121,7 +125,7 @@ private VectorStoreGenericDataModel<TKey> InternalMapFromStorageToDataModel<TKey
// Process data properties.
foreach (var property in this._propertyReader.DataProperties)
{
if (storageModel.TryGetValue(this._propertyReader.StoragePropertyNamesMap[property.DataModelPropertyName], out var dataValue))
if (storageModel.TryGetValue(this._propertyReader.GetStoragePropertyName(property.DataModelPropertyName), out var dataValue))
{
dataProperties.Add(property.DataModelPropertyName, dataValue);
}
Expand All @@ -132,9 +136,11 @@ private VectorStoreGenericDataModel<TKey> InternalMapFromStorageToDataModel<TKey
{
foreach (var property in this._propertyReader.VectorProperties)
{
if (storageModel.TryGetValue(this._propertyReader.StoragePropertyNamesMap[property.DataModelPropertyName], out var vectorValue))
if (storageModel.TryGetValue(this._propertyReader.GetStoragePropertyName(property.DataModelPropertyName), out var vectorValue) &&
vectorValue is byte[] vectorBytes)
{
vectorProperties.Add(property.DataModelPropertyName, vectorValue);
var vector = SqliteVectorStoreRecordPropertyMapping.MapVectorForDataModel(vectorBytes);
vectorProperties.Add(property.DataModelPropertyName, vector);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.

using Microsoft.Data.Sqlite;
using Microsoft.Extensions.VectorData;
using Microsoft.SemanticKernel.Connectors.Sqlite;
using Microsoft.SemanticKernel.Data;

namespace Microsoft.SemanticKernel;

Expand Down Expand Up @@ -32,17 +32,17 @@ public static IKernelBuilder AddSqliteVectorStore(
/// Register a SQLite <see cref="IVectorStore"/> with the specified service ID.
/// </summary>
/// <param name="builder">The builder to register the <see cref="IVectorStoreRecordCollection{TKey, TRecord}"/> on.</param>
/// <param name="connection"><see cref="SqliteConnection"/> that will be used to manage the data in SQLite.</param>
/// <param name="connectionString">Connection string for <see cref="SqliteConnection"/>.</param>
/// <param name="options">Optional options to further configure the <see cref="IVectorStore"/>.</param>
/// <param name="serviceId">An optional service id to use as the service key.</param>
/// <returns>Kernel builder.</returns>
public static IKernelBuilder AddSqliteVectorStore(
this IKernelBuilder builder,
SqliteConnection connection,
string connectionString,
SqliteVectorStoreOptions? options = default,
string? serviceId = default)
{
builder.Services.AddSqliteVectorStore(connection, options, serviceId);
builder.Services.AddSqliteVectorStore(connectionString, options, serviceId);
return builder;
}

Expand All @@ -63,7 +63,6 @@ public static IKernelBuilder AddSqliteVectorStoreRecordCollection<TKey, TRecord>
SqliteVectorStoreRecordCollectionOptions<TRecord>? options = default,
string? serviceId = default)
where TKey : notnull
where TRecord : class
{
builder.Services.AddSqliteVectorStoreRecordCollection<TKey, TRecord>(collectionName, options, serviceId);
return builder;
Expand All @@ -76,20 +75,19 @@ public static IKernelBuilder AddSqliteVectorStoreRecordCollection<TKey, TRecord>
/// <typeparam name="TRecord">The type of the record.</typeparam>
/// <param name="builder">The builder to register the <see cref="IVectorStoreRecordCollection{TKey, TRecord}"/> on.</param>
/// <param name="collectionName">The name of the collection.</param>
/// <param name="connection"><see cref="SqliteConnection"/> that will be used to manage the data in SQLite.</param>
/// <param name="connectionString">Connection string for <see cref="SqliteConnection"/>.</param>
/// <param name="options">Optional options to further configure the <see cref="IVectorStoreRecordCollection{TKey, TRecord}"/>.</param>
/// <param name="serviceId">An optional service id to use as the service key.</param>
/// <returns>Kernel builder.</returns>
public static IKernelBuilder AddSqliteVectorStoreRecordCollection<TKey, TRecord>(
this IKernelBuilder builder,
string collectionName,
SqliteConnection connection,
string connectionString,
SqliteVectorStoreRecordCollectionOptions<TRecord>? options = default,
string? serviceId = default)
where TKey : notnull
where TRecord : class
{
builder.Services.AddSqliteVectorStoreRecordCollection<TKey, TRecord>(collectionName, connection, options, serviceId);
builder.Services.AddSqliteVectorStoreRecordCollection<TKey, TRecord>(collectionName, connectionString, options, serviceId);
return builder;
}
}
Loading
Loading