Skip to content
Closed
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,18 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
where TKey : notnull
where TRecord : class
{
IDatabase database;
VectorStore vectorStore;
VectorStoreCollection<TKey, TRecord> collection = null;
var kernel = iWwantToRun.Kernel;

//TODO: If the logic becomes overly complex in the future, different combinations can be considered to be separated into different libraries

switch (vectorDb.Type)
{
case VectorDBType.Memory:
{
vectorStore = new InMemoryVectorStore();
// Retrieve from DI container (registered via ConfigVectorStore)
vectorStore = kernel.Services.GetRequiredService<VectorStore>();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
Expand All @@ -263,12 +264,9 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
}
case VectorDBType.Redis:
{
database = ConnectionMultiplexer.Connect(vectorDb.ConnectionString).GetDatabase();
using (var redisVectorStore = new RedisVectorStore(database,
new() { StorageType = RedisStorageType.Json }))
{
collection = redisVectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
}
// Retrieve from DI container (registered via ConfigVectorStore)
vectorStore = kernel.Services.GetRequiredService<VectorStore>();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
case VectorDBType.Milvus:
Expand All @@ -293,12 +291,14 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe
}
case VectorDBType.Qdrant:
{
vectorStore = new QdrantVectorStore(new QdrantClient(vectorDb.ConnectionString), ownsClient: true);
// Retrieve from DI container (registered via ConfigVectorStore)
vectorStore = kernel.Services.GetRequiredService<VectorStore>();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
default:
vectorStore = new InMemoryVectorStore();
// For unsupported types, try to get from DI or throw an error
vectorStore = kernel.Services.GetRequiredService<VectorStore>();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
Expand Down
Loading