From ba9180120db22ac8fd25c2839c6fc4e71a926827 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Wed, 7 Aug 2024 09:57:07 -0500 Subject: [PATCH] rename --- .../BotSharp.Abstraction/Knowledges/IKnowledgeService.cs | 2 +- .../Knowledges/Models/KnowledgeCollectionData.cs | 2 +- .../Knowledges/Models/KnowledgeFilter.cs | 2 +- .../{UuidPagination.cs => StringIdPagination.cs} | 4 ++-- .../BotSharp.Abstraction/VectorStorage/IVectorDb.cs | 2 +- .../Controllers/KnowledgeBaseController.cs | 4 ++-- .../Knowledges/KnowledgeCollectionDataViewModel.cs | 6 +++--- .../MemVecDb/MemVectorDatabase.cs | 2 +- .../Services/KnowledgeService.List.cs | 4 ++-- src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs | 2 +- src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs | 8 ++++---- 11 files changed, 19 insertions(+), 19 deletions(-) rename src/Infrastructure/BotSharp.Abstraction/Utilities/{UuidPagination.cs => StringIdPagination.cs} (71%) diff --git a/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs b/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs index cd0035c7..f7e1464e 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Knowledges/IKnowledgeService.cs @@ -14,6 +14,6 @@ public interface IKnowledgeService #region List Task GetKnowledgeCollectionInfo(string collectionName); - Task> GetKnowledgeCollectionData(KnowledgeFilter filter); + Task> GetKnowledgeCollectionData(KnowledgeFilter filter); #endregion } diff --git a/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeCollectionData.cs b/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeCollectionData.cs index de3e521b..d013529f 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeCollectionData.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeCollectionData.cs @@ -3,7 +3,7 @@ namespace BotSharp.Abstraction.Knowledges.Models; public class KnowledgeCollectionData { public string Id { get; set; } - public string Text { get; set; } + public string Question { get; set; } public string Answer { get; set; } public float[]? Vector { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeFilter.cs b/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeFilter.cs index 86957b48..553b0b2c 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeFilter.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Knowledges/Models/KnowledgeFilter.cs @@ -1,6 +1,6 @@ namespace BotSharp.Abstraction.Knowledges.Models; -public class KnowledgeFilter : UuidPagination +public class KnowledgeFilter : StringIdPagination { [JsonPropertyName("collection_name")] public string CollectionName { get; set; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Utilities/UuidPagination.cs b/src/Infrastructure/BotSharp.Abstraction/Utilities/StringIdPagination.cs similarity index 71% rename from src/Infrastructure/BotSharp.Abstraction/Utilities/UuidPagination.cs rename to src/Infrastructure/BotSharp.Abstraction/Utilities/StringIdPagination.cs index 45f46422..d8e4d355 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Utilities/UuidPagination.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Utilities/StringIdPagination.cs @@ -1,12 +1,12 @@ namespace BotSharp.Abstraction.Utilities; -public class UuidPagination : Pagination +public class StringIdPagination : Pagination { [JsonPropertyName("start_id")] public string? StartId { get; set; } } -public class UuidPagedItems : PagedItems +public class StringIdPagedItems : PagedItems { public new ulong Count { get; set; } diff --git a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs index 1e1122a5..ce61b134 100644 --- a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs +++ b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/IVectorDb.cs @@ -6,7 +6,7 @@ public interface IVectorDb { Task> GetCollections(); Task GetCollectionInfo(string collectionName); - Task> GetCollectionData(KnowledgeFilter filter); + Task> GetCollectionData(KnowledgeFilter filter); Task CreateCollection(string collectionName, int dim); Task Upsert(string collectionName, string id, float[] vector, string text, Dictionary? payload = null); Task> Search(string collectionName, float[] vector, string returnFieldName, int limit = 5, float confidence = 0.5f); diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs index 21df9840..df17bfe2 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/KnowledgeBaseController.cs @@ -100,13 +100,13 @@ public class KnowledgeBaseController : ControllerBase } [HttpPost("/knowledge/collection/data")] - public async Task> GetKnowledgeCollectionData([FromBody] KnowledgeFilter filter) + public async Task> GetKnowledgeCollectionData([FromBody] KnowledgeFilter filter) { var data = await _knowledgeService.GetKnowledgeCollectionData(filter); var items = data.Items?.Select(x => KnowledgeCollectionDataViewModel.ToViewModel(x))? .ToList() ?? new List(); - return new UuidPagedItems + return new StringIdPagedItems { Count = data.Count, NextId = data.NextId, diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionDataViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionDataViewModel.cs index 7f8aa087..16ebadda 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionDataViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/KnowledgeCollectionDataViewModel.cs @@ -8,8 +8,8 @@ public class KnowledgeCollectionDataViewModel [JsonPropertyName("id")] public string Id { get; set; } - [JsonPropertyName("text")] - public string Text { get; set; } + [JsonPropertyName("question")] + public string Question { get; set; } [JsonPropertyName("answer")] public string Answer { get; set; } @@ -23,7 +23,7 @@ public class KnowledgeCollectionDataViewModel return new KnowledgeCollectionDataViewModel { Id = data.Id, - Text = data.Text, + Question = data.Question, Answer = data.Answer, Vector = data.Vector }; diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs index de74e669..a7c7a7f4 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/MemVecDb/MemVectorDatabase.cs @@ -32,7 +32,7 @@ public class MemVectorDatabase : IVectorDb }; } - public Task> GetCollectionData(KnowledgeFilter filter) + public Task> GetCollectionData(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 950a5246..3f9ae419 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.List.cs @@ -16,7 +16,7 @@ public partial class KnowledgeService } } - public async Task> GetKnowledgeCollectionData(KnowledgeFilter filter) + public async Task> GetKnowledgeCollectionData(KnowledgeFilter filter) { try { @@ -26,7 +26,7 @@ public partial class KnowledgeService catch (Exception ex) { _logger.LogWarning($"Error when getting knowledge collectio data. {ex.Message}\r\n{ex.InnerException}"); - return new UuidPagedItems(); + return new StringIdPagedItems(); } } } diff --git a/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs b/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs index b6831e05..a06df43c 100644 --- a/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs +++ b/src/Plugins/BotSharp.Plugin.MetaAI/Providers/FaissDb.cs @@ -19,7 +19,7 @@ public class FaissDb : IVectorDb throw new NotImplementedException(); } - public Task> GetCollectionData(KnowledgeFilter filter) + public Task> GetCollectionData(KnowledgeFilter filter) { throw new NotImplementedException(); } diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index 9fb9e57d..2a75a414 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -54,13 +54,13 @@ public class QdrantDb : IVectorDb }; } - public async Task> GetCollectionData(KnowledgeFilter filter) + public async Task> GetCollectionData(KnowledgeFilter filter) { var client = GetClient(); var exists = await client.CollectionExistsAsync(filter.CollectionName); if (!exists) { - return new UuidPagedItems(); + return new StringIdPagedItems(); } var totalPointCount = await client.CountAsync(filter.CollectionName); @@ -70,12 +70,12 @@ public class QdrantDb : IVectorDb var points = response?.Result?.Select(x => new KnowledgeCollectionData { Id = x.Id?.Uuid ?? string.Empty, - Text = x.Payload.ContainsKey(KnowledgePayloadName.Text) ? x.Payload[KnowledgePayloadName.Text].StringValue : string.Empty, + Question = x.Payload.ContainsKey(KnowledgePayloadName.Text) ? x.Payload[KnowledgePayloadName.Text].StringValue : string.Empty, Answer = x.Payload.ContainsKey(KnowledgePayloadName.Answer) ? x.Payload[KnowledgePayloadName.Answer].StringValue : string.Empty, Vector = filter.WithVector ? x.Vectors?.Vector?.Data?.ToArray() : null })?.ToList() ?? new List(); - return new UuidPagedItems + return new StringIdPagedItems { Count = totalPointCount, NextId = response?.NextPageOffset?.Uuid,