-
Notifications
You must be signed in to change notification settings - Fork 31
Developer microsoft memory kernel #160
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
Changes from all commits
4a9d864
80758e4
d6b7679
c3f615e
2646df2
16a6493
d9b8829
5bcd0ed
bda2cbe
7c2f738
3649a93
bb6eda4
3e52f9b
4b5277c
ccc71b2
71f9006
9dbc492
b0fd111
e217720
2306ad6
7edd730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||
| { | ||||||||||||||||||
|
|
@@ -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: | ||||||||||||||||||
|
|
@@ -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 | ||||||||||||||||||
|
|
@@ -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(); | ||||||||||||||||||
| 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
|
||||||||||||||||||
| 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); | |
| } |
JeffreySu marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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, | ||||||
|
||||||
| // Pinecon=11, | |
| // Pinecone=11, |
There was a problem hiding this comment.
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.