diff --git a/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs b/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs index b93e905b..f2eb82fe 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs @@ -13,7 +13,6 @@ public interface IKnowledgeService Task> GetAnswer(KnowledgeRetrievalModel retrievalModel); #region List - Task GetKnowledgeCollectionInfo(string collectionName); Task> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter); #endregion } diff --git a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs index 266dd968..50788756 100644 --- a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs +++ b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs @@ -5,7 +5,6 @@ namespace BotSharp.Abstraction.VectorStorage; public interface IVectorDb { Task> GetCollections(); - Task GetCollectionInfo(string collectionName); Task> GetCollectionData(string collectionName, KnowledgeFilter filter); Task CreateCollection(string collectionName, int dim); Task Upsert(string collectionName, string id, float[] vector, string text, Dictionary? payload = null); diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs index ae67ca37..cd01ec05 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs @@ -92,12 +92,6 @@ public class KnowledgeBaseController : ControllerBase return Ok(new { count = files.Count, size }); } - [HttpGet("/knowledge/{collection}/info")] - public async Task GetKnowledgeCollectionInfo([FromRoute] string collection) - { - var info = await _knowledgeService.GetKnowledgeCollectionInfo(collection); - return KnowledgeCollectionInfoViewModel.ToViewModel(info); - } [HttpPost("/knowledge/{collection}/data")] public async Task> GetKnowledgeCollectionData([FromRoute] string collection, [FromBody] KnowledgeFilter filter) diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionInfoViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionInfoViewModel.cs deleted file mode 100644 index 65f5d979..00000000 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionInfoViewModel.cs +++ /dev/null @@ -1,22 +0,0 @@ -using BotSharp.Abstraction.Knowledges.Models; -using System.Text.Json.Serialization; - -namespace BotSharp.OpenAPI.ViewModels.Knowledges; - -public class KnowledgeCollectionInfoViewModel -{ - [JsonPropertyName("data_count")] - public ulong DataCount { get; set; } - - [JsonPropertyName("vector_count")] - public ulong VectorCount { get; set; } - - public static KnowledgeCollectionInfoViewModel ToViewModel(KnowledgeCollectionInfo info) - { - return new KnowledgeCollectionInfoViewModel - { - DataCount = info.DataCount, - VectorCount = info.VectorCount - }; - } -} diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs index b481d127..61598a71 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs @@ -18,20 +18,6 @@ public class MemVectorDatabase : IVectorDb return _collections.Select(x => x.Key).ToList(); } - public async Task GetCollectionInfo(string collectionName) - { - if (_vectors.TryGetValue(collectionName, out var info)) - { - info = new List(); - } - - return new KnowledgeCollectionInfo - { - DataCount = (ulong)(info?.Count ?? 0), - VectorCount = (ulong)(info?.Count(x => x.Vector != null && x.Vector.Length > 0) ?? 0) - }; - } - public Task> GetCollectionData(string collectionName, KnowledgeFilter filter) { throw new NotImplementedException(); diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs index dff57ec6..2f8547f4 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs @@ -2,20 +2,6 @@ namespace BotSharp.Plugin.KnowledgeBase.Services; public partial class KnowledgeService { - public async Task GetKnowledgeCollectionInfo(string collectionName) - { - try - { - var db = GetVectorDb(); - return await db.GetCollectionInfo(collectionName); - } - catch (Exception ex) - { - _logger.LogWarning($"Error when getting knowledge collectio info. {ex.Message}\r\n{ex.InnerException}"); - return new KnowledgeCollectionInfo(); - } - } - public async Task> GetKnowledgeCollectionData(string collectionName, KnowledgeFilter filter) { try diff --git a/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs b/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs index ad408824..5983d49a 100644 --- a/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs +++ b/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs @@ -14,11 +14,6 @@ public class FaissDb : IVectorDb throw new NotImplementedException(); } - public Task GetCollectionInfo(string collectionName) - { - throw new NotImplementedException(); - } - public Task> GetCollectionData(string collectionName, KnowledgeFilter filter) { throw new NotImplementedException(); diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index 997215ca..d331e28e 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -39,24 +39,10 @@ public class QdrantDb : IVectorDb return collections.ToList(); } - public async Task GetCollectionInfo(string collectionName) - { - var client = GetClient(); - - var exists = await client.CollectionExistsAsync(collectionName); - if (!exists) return new KnowledgeCollectionInfo(); - - var info = await client.GetCollectionInfoAsync(collectionName); - return new KnowledgeCollectionInfo - { - DataCount = info.PointsCount, - VectorCount = info.VectorsCount - }; - } - public async Task> GetCollectionData(string collectionName, KnowledgeFilter filter) { var client = GetClient(); + var exists = await client.CollectionExistsAsync(collectionName); if (!exists) { diff --git a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs index 876bd149..c831d15b 100644 --- a/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs +++ b/src/Plugins/BotSharp.Plugin.SemanticKernel/SemanticKernelMemoryStoreProvider.cs @@ -29,11 +29,6 @@ namespace BotSharp.Plugin.SemanticKernel throw new System.NotImplementedException(); } - public Task GetCollectionInfo(string collectionName) - { - throw new System.NotImplementedException(); - } - public async Task> GetCollections() { var result = new List();