Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4a9d864
Optimize Problem
zhao365845726 Oct 10, 2025
80758e4
Opitmize the VectorDBType define position.
zhao365845726 Oct 30, 2025
d6b7679
Merge pull request #159 from Senparc/Developer-MicrosoftMemoryKernel-zmz
JeffreySu Oct 31, 2025
c3f615e
Update Program.cs
JeffreySu Oct 31, 2025
2646df2
Merge branch 'Developer-MicrosoftMemoryKernel' of https://github.com/…
JeffreySu Oct 31, 2025
16a6493
chore: update project versions and add Qdrant support in VectorDBType
JeffreySu Nov 1, 2025
d9b8829
Update src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExten…
JeffreySu Nov 1, 2025
5bcd0ed
Update src/Senparc.AI/Interfaces/ISenparcAiSetting.cs
JeffreySu Nov 1, 2025
bda2cbe
Update src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExten…
JeffreySu Nov 1, 2025
7c2f738
Update src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExten…
JeffreySu Nov 1, 2025
3649a93
Update src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExten…
JeffreySu Nov 1, 2025
bb6eda4
Update src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExten…
JeffreySu Nov 1, 2025
3e52f9b
Initial plan
Copilot Nov 1, 2025
4b5277c
Initial plan
Copilot Nov 1, 2025
ccc71b2
Wrap disposable vector stores in using statements to ensure proper di…
Copilot Nov 1, 2025
71f9006
Fix VectorStore lifecycle management and remove incorrect using state…
Copilot Nov 1, 2025
9dbc492
Merge pull request #161 from Senparc/copilot/sub-pr-160
JeffreySu Nov 1, 2025
b0fd111
Merge pull request #162 from Senparc/copilot/sub-pr-160-again
JeffreySu Nov 1, 2025
e217720
Initial plan
Copilot Nov 1, 2025
2306ad6
Fix VectorStore disposal issue by removing incorrect using statements
Copilot Nov 1, 2025
7edd730
Merge pull request #164 from Senparc/copilot/sub-pr-160-yet-again
JeffreySu Nov 1, 2025
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
6 changes: 1 addition & 5 deletions Samples/Senparc.AI.Samples.Consoles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
var config = configBuilder.Build();
Console.WriteLine("完成 ServiceCollection 和 ConfigurationBuilder 初始化");

//更多绑定操作参见:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2
var senparcSetting = new SenparcSetting();
config.GetSection("SenparcSetting").Bind(senparcSetting);

var services = new ServiceCollection();

services.AddSenparcGlobalServices(config)
Expand All @@ -40,7 +36,7 @@

var serviceProvider = services.BuildServiceProvider();

IRegisterService register = RegisterService.Start(senparcSetting)
IRegisterService register = RegisterService.Start()
.UseSenparcGlobal()
.UseSenparcAI();

Expand Down
2 changes: 1 addition & 1 deletion src/Senparc.AI.Agents/Senparc.AI.Agents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.5.6.1</Version>
<Version>0.5.7</Version>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<AssemblyName>Senparc.AI.Agents</AssemblyName>
Expand Down
153 changes: 45 additions & 108 deletions src/Senparc.AI.Kernel/KernelConfigExtensions/KernelConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Senparc.AI.Interfaces.VectorDB;

namespace Senparc.AI.Kernel.Handlers
{
Expand Down Expand Up @@ -170,83 +171,53 @@ public static IWantToConfig ConfigVectorStore(this IWantToConfig iWantToConfig,

switch (vectorDb.Type)
{
case VectorDB.VectorDBType.AzureAISearch:
{
break;
}
case VectorDB.VectorDBType.CosmosDBMongoDB:
{
break;
}
case VectorDB.VectorDBType.CosmosDBNoSQL:
{
break;
}
case VectorDB.VectorDBType.Couchbase:
{
break;
}
case VectorDB.VectorDBType.Elasticsearch:
{
break;
}
case VectorDB.VectorDBType.Chroma:
{
break;
}
case VectorDB.VectorDBType.Milvus:
{
break;
}
case VectorDB.VectorDBType.MongoDB:
{
break;
}
case VectorDB.VectorDBType.Postgres:
case VectorDBType.Memory:
{
servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.Qdrant:
case VectorDBType.HardDisk:
{
servives.AddQdrantVectorStore(vectorDb.ConnectionString);
servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.Redis:
//case VectorDBType.Qdrant:
// {
// servives.AddQdrantVectorStore(vectorDb.ConnectionString);
// break;
// }
case VectorDBType.Redis:
{
servives.AddRedisVectorStore(vectorDb.ConnectionString);
break;
}
case VectorDB.VectorDBType.SqlServer:
{
break;
}
case VectorDB.VectorDBType.SQLite:
case VectorDBType.Milvus:
{
// servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.Weaviate:
case VectorDBType.Chroma:
{
// servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.Faiss:
case VectorDBType.PostgreSQL:
{
// servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.InMemory:
case VectorDBType.Sqlite:
{
servives.AddInMemoryVectorStore();
// servives.AddInMemoryVectorStore();
break;
}
case VectorDB.VectorDBType.JDBC:
case VectorDBType.SqlServer:
{
break;
}
case VectorDB.VectorDBType.Pinecon:
{
break;
}
case VectorDB.VectorDBType.VolatileInMemory:
case VectorDBType.Qdrant:
{
servives.AddQdrantVectorStore(vectorDb.ConnectionString);
break;
}
default:
Expand All @@ -268,6 +239,12 @@ public static IWantToConfig ConfigVectorStore(this IWantToConfig iWantToConfig,
/// <param name="name"></param>
/// <param name="vectorStoreRecordDefinition"></param>
/// <returns></returns>
/// <remarks>
/// Note: VectorStore instances created in this method are not explicitly disposed.
/// The VectorStoreCollection returned may maintain a reference to the VectorStore and require it to remain alive.
/// For proper resource management, consider using dependency injection to manage VectorStore lifecycle
/// or ensure the collection is disposed when no longer needed.
/// </remarks>
public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRecord>(this IWantToRun iWwantToRun, VectorDB vectorDb, string name, VectorStoreCollectionDefinition? vectorStoreRecordDefinition = null)
where TKey : notnull
where TRecord : class
Expand All @@ -280,93 +257,53 @@ public static VectorStoreCollection<TKey, TRecord> GetVectorCollection<TKey, TRe

switch (vectorDb.Type)
{
case VectorDB.VectorDBType.AzureAISearch:
{
break;
}
case VectorDB.VectorDBType.CosmosDBMongoDB:
case VectorDBType.Memory:
{
vectorStore = new InMemoryVectorStore();
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposable 'InMemoryVectorStore' is created but not disposed.

Copilot uses AI. Check for mistakes.
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
case VectorDB.VectorDBType.CosmosDBNoSQL:
case VectorDBType.HardDisk:
{
break;
}
case VectorDB.VectorDBType.Couchbase:
case VectorDBType.Redis:
{
database = ConnectionMultiplexer.Connect(vectorDb.ConnectionString).GetDatabase();
vectorStore = new RedisVectorStore(database,
new() { StorageType = RedisStorageType.Json });
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
Comment on lines +273 to +275
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposable 'RedisVectorStore' is created but not disposed.

Suggested change
vectorStore = new RedisVectorStore(database,
new() { StorageType = RedisStorageType.Json });
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
using (var redisVectorStore = new RedisVectorStore(database,
new() { StorageType = RedisStorageType.Json }))
{
collection = redisVectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
}

Copilot uses AI. Check for mistakes.
break;
}
case VectorDB.VectorDBType.Elasticsearch:
case VectorDBType.Milvus:
{
break;
}
case VectorDB.VectorDBType.Chroma:
case VectorDBType.Chroma:
{
break;
}
case VectorDB.VectorDBType.Milvus:
case VectorDBType.PostgreSQL:
{
break;
}
case VectorDB.VectorDBType.MongoDB:
case VectorDBType.Sqlite:
{
break;
}
case VectorDB.VectorDBType.Postgres:
case VectorDBType.SqlServer:
{
break;
}
case VectorDB.VectorDBType.Qdrant:
case VectorDBType.Qdrant:
{
database = null;
vectorStore = new QdrantVectorStore(new QdrantClient(vectorDb.ConnectionString), ownsClient: true);
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
case VectorDB.VectorDBType.Redis:
database = ConnectionMultiplexer.Connect(vectorDb.ConnectionString).GetDatabase();
vectorStore = new RedisVectorStore(database,
new() { StorageType = RedisStorageType.Json });

collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
case VectorDB.VectorDBType.SqlServer:
{

break;
}
case VectorDB.VectorDBType.SQLite:
{
break;
}
case VectorDB.VectorDBType.Weaviate:
{

break;
}
case VectorDB.VectorDBType.Faiss:
{
break;
}
case VectorDB.VectorDBType.InMemory:
{
vectorStore = new InMemoryVectorStore();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}
case VectorDB.VectorDBType.JDBC:
{
break;
}
case VectorDB.VectorDBType.Pinecon:
{
break;
}
case VectorDB.VectorDBType.VolatileInMemory:
{
break;
}
default:
vectorStore = new InMemoryVectorStore();
collection = vectorStore.GetCollection<TKey, TRecord>(name, vectorStoreRecordDefinition);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Senparc.AI.Kernel/Senparc.AI.Kernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>0.25.1</Version>
<Version>0.25.3</Version>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AssemblyName>Senparc.AI.Kernel</AssemblyName>
Expand Down
24 changes: 12 additions & 12 deletions src/Senparc.AI/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ public enum ConfigModel
}

#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释
public enum VectorDBType
{
Memory,
HardDisk,
Redis,
Mulivs,
Chroma,
PostgreSQL,
Sqlite,
SqlServer,
Default = Memory,
}
//public enum VectorDBType
//{
// Memory,
// HardDisk,
// Redis,
// Mulivs,
// Chroma,
// PostgreSQL,
// Sqlite,
// SqlServer,
// Default = Memory,
//}
#pragma warning restore CS1591 // 缺少对公共可见类型或成员的 XML 注释
}
76 changes: 45 additions & 31 deletions src/Senparc.AI/Interfaces/ISenparcAiSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,37 +187,51 @@ public class VectorDB

public enum VectorDBType
{
//Memory,
//HardDisk,
//Redis,
//Mulivs,
//Chroma,
//PostgreSQL,
//Sqlite,
//SqlServer,

/* 注意:枚举值一旦确定,不能再进行修改 */

AzureAISearch=0,
CosmosDBMongoDB=1,
CosmosDBNoSQL=2,
Chroma=3, //Planed
Couchbase=4,
Elasticsearch=5,
Faiss=6,
InMemory=7,
JDBC=8,
Milvus=9, //Planed (not included in https://learn.microsoft.com/en-us/semantic-kernel/concepts/vector-store-connectors/out-of-the-box-connectors/inmemory-connector?pivots=programming-language-csharp)
MongoDB=10,
Pinecon=11,
Postgres=12,
Qdrant=13,
Redis=14,
SqlServer=15, //Planed
SQLite=16,
VolatileInMemory=17,
Weaviate=18,
Default = InMemory,
Memory,
HardDisk,
Redis,
Milvus,
Chroma,
PostgreSQL,
Sqlite,
SqlServer,
Qdrant,
Default = Memory,
}

//public enum VectorDBType
//{
// //Memory,
// //HardDisk,
// //Redis,
// //Mulivs,
// //Chroma,
// //PostgreSQL,
// //Sqlite,
// //SqlServer,

// /* 注意:枚举值一旦确定,不能再进行修改 */

// AzureAISearch=0,
// CosmosDBMongoDB=1,
// CosmosDBNoSQL=2,
// Chroma=3, //Planed
// Couchbase=4,
// Elasticsearch=5,
// Faiss=6,
// InMemory=7,
// JDBC=8,
// Milvus=9, //Planed (not included in https://learn.microsoft.com/en-us/semantic-kernel/concepts/vector-store-connectors/out-of-the-box-connectors/inmemory-connector?pivots=programming-language-csharp)
// MongoDB=10,
// Pinecon=11,
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible typo: 'Pinecon' should likely be 'Pinecone' (the vector database name) in commented code.

Suggested change
// Pinecon=11,
// Pinecone=11,

Copilot uses AI. Check for mistakes.
// Postgres=12,
// Qdrant=13,
// Redis=14,
// SqlServer=15, //Planed
// SQLite=16,
// VolatileInMemory=17,
// Weaviate=18,
// Default = InMemory,
//}
}
}
Loading
Loading