Skip to content

Commit 3a41be8

Browse files
committed
Revert "[MEDI] Remove collection key type workaround (#7010)"
This reverts commit a369be9.
1 parent 6da6a21 commit 3a41be8

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
<XUnitRunnerVisualStudioVersion>2.8.2</XUnitRunnerVisualStudioVersion>
228228
<!-- MEVD is still part of the Semantic Kernel repo -->
229229
<MicrosoftExtensionsVectorDataAbstractionsVersion>9.7.0</MicrosoftExtensionsVectorDataAbstractionsVersion>
230-
<MicrosoftSemanticKernelConnectorsVersion>1.67.0-preview</MicrosoftSemanticKernelConnectorsVersion>
230+
<MicrosoftSemanticKernelConnectorsVersion>1.66.0-preview</MicrosoftSemanticKernelConnectorsVersion>
231231
<MarkdigSignedVersion>0.43.0</MarkdigSignedVersion>
232232
</PropertyGroup>
233233
</Project>

src/Libraries/Microsoft.Extensions.DataIngestion/Microsoft.Extensions.DataIngestion.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@
2929
<PackageReference Include="System.Collections.Immutable" />
3030
</ItemGroup>
3131

32-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
33-
<!-- Workaround https://github.com/microsoft/semantic-kernel/issues/13316 -->
34-
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonVersion)" />
35-
</ItemGroup>
36-
3732
</Project>

src/Libraries/Microsoft.Extensions.DataIngestion/Writers/VectorStoreWriter.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public sealed class VectorStoreWriter<T> : IngestionChunkWriter<T>
2626
private readonly VectorStore _vectorStore;
2727
private readonly int _dimensionCount;
2828
private readonly VectorStoreWriterOptions _options;
29+
private readonly bool _keysAreStrings;
2930

3031
private VectorStoreCollection<object, Dictionary<string, object?>>? _vectorStoreCollection;
3132

@@ -42,6 +43,12 @@ public VectorStoreWriter(VectorStore vectorStore, int dimensionCount, VectorStor
4243
_vectorStore = Throw.IfNull(vectorStore);
4344
_dimensionCount = Throw.IfLessThanOrEqual(dimensionCount, 0);
4445
_options = options ?? new VectorStoreWriterOptions();
46+
47+
// Not all vector store support string as the key type, examples:
48+
// Qdrant: https://github.com/microsoft/semantic-kernel/blob/28ea2f4df872e8fd03ef0792ebc9e1989b4be0ee/dotnet/src/VectorData/Qdrant/QdrantCollection.cs#L104
49+
// When https://github.com/microsoft/semantic-kernel/issues/13141 gets released,
50+
// we need to remove this workaround.
51+
_keysAreStrings = vectorStore.GetType().Name != "QdrantVectorStore";
4552
}
4653

4754
/// <summary>
@@ -78,7 +85,7 @@ public override async Task WriteAsync(IAsyncEnumerable<IngestionChunk<T>> chunks
7885
var key = Guid.NewGuid();
7986
Dictionary<string, object?> record = new()
8087
{
81-
[KeyName] = key,
88+
[KeyName] = _keysAreStrings ? key.ToString() : key,
8289
[ContentName] = chunk.Content,
8390
[EmbeddingName] = chunk.Content,
8491
[ContextName] = chunk.Context,
@@ -122,7 +129,7 @@ private VectorStoreCollectionDefinition GetVectorStoreRecordDefinition(Ingestion
122129
{
123130
Properties =
124131
{
125-
new VectorStoreKeyProperty(KeyName, typeof(Guid)),
132+
new VectorStoreKeyProperty(KeyName, _keysAreStrings ? typeof(string) : typeof(Guid)),
126133

127134
// By using T as the type here we allow the vector store
128135
// to handle the conversion from T to the actual vector type it supports.

0 commit comments

Comments
 (0)