Skip to content

Commit 7edd730

Browse files
authored
Merge pull request #164 from Senparc/copilot/sub-pr-160-yet-again
[WIP] Update based on feedback from PR #160
2 parents b0fd111 + 2306ad6 commit 7edd730

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExtensions.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
250250
where TRecord : class
251251
{
252252
IDatabase database;
253+
VectorStore vectorStore;
253254
VectorStoreCollection<TKey, TRecord> collection = null;
254255

255256
//TODO: If the logic becomes overly complex in the future, different combinations can be considered to be separated into different libraries
@@ -258,10 +259,8 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
258259
{
259260
case VectorDBType.Memory:
260261
{
261-
using (var inMemoryVectorStore = new InMemoryVectorStore())
262-
{
263-
collection = inMemoryVectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
264-
}
262+
vectorStore = new InMemoryVectorStore();
263+
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
265264
break;
266265
}
267266
case VectorDBType.HardDisk:
@@ -298,17 +297,13 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
298297
}
299298
case VectorDBType.Qdrant:
300299
{
301-
using (var qdrantVectorStore = new QdrantVectorStore(new QdrantClient(vectorDb.ConnectionString), ownsClient: true))
302-
{
303-
collection = qdrantVectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
304-
}
300+
vectorStore = new QdrantVectorStore(new QdrantClient(vectorDb.ConnectionString), ownsClient: true);
301+
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
305302
break;
306303
}
307304
default:
308-
using (var inMemoryVectorStore = new InMemoryVectorStore())
309-
{
310-
collection = inMemoryVectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
311-
}
305+
vectorStore = new InMemoryVectorStore();
306+
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
312307
break;
313308
}
314309

0 commit comments

Comments
 (0)