From 5ffbbaa41f91f9ed8acc50ff94036b2a6cf7a1d4 Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Thu, 14 Aug 2025 17:51:09 -0500 Subject: [PATCH] add payload schema --- .../Models/VectorCollectionDetails.cs | 20 +++++++++++++++++++ .../View/VectorCollectionDetailsViewModel.cs | 3 ++- .../Services/KnowledgeService.Vector.cs | 2 +- .../BotSharp.Plugin.Qdrant/QdrantDb.cs | 10 +++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/Models/VectorCollectionDetails.cs b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/Models/VectorCollectionDetails.cs index f97c4064..dbda8efd 100644 --- a/src/Infrastructure/BotSharp.Abstraction/VectorStorage/Models/VectorCollectionDetails.cs +++ b/src/Infrastructure/BotSharp.Abstraction/VectorStorage/Models/VectorCollectionDetails.cs @@ -25,6 +25,9 @@ public class VectorCollectionDetails [JsonPropertyName("basic_info")] public VectorCollectionConfig? BasicInfo { get; set; } + + [JsonPropertyName("payload_schema")] + public List PayloadSchema { get; set; } = []; } public class VectorCollectionDetailConfig @@ -48,4 +51,21 @@ public class VectorCollectionDetailConfigParam [JsonPropertyName("read_fan_out_factor")] public uint? ReadFanOutFactor { get; set; } +} + +public class PayloadSchemaDetail +{ + [JsonPropertyName("field_name")] + public string FieldName { get; set; } = null!; + + [JsonPropertyName("field_data_type")] + public string FieldDataType { get; set; } = null!; + + [JsonPropertyName("data_count")] + public ulong DataCount { get; set; } + + public override string ToString() + { + return $"{FieldName} ({FieldDataType})"; + } } \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/View/VectorCollectionDetailsViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/View/VectorCollectionDetailsViewModel.cs index b0506877..b55981b5 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/View/VectorCollectionDetailsViewModel.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Knowledges/View/VectorCollectionDetailsViewModel.cs @@ -17,7 +17,8 @@ public class VectorCollectionDetailsViewModel : VectorCollectionDetails IndexedVectorsCount = model.IndexedVectorsCount, PointsCount = model.PointsCount, InnerConfig = model.InnerConfig, - BasicInfo = model.BasicInfo + BasicInfo = model.BasicInfo, + PayloadSchema = model.PayloadSchema }; } } diff --git a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Vector.cs b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Vector.cs index 67d546e1..76f4ac30 100644 --- a/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Vector.cs +++ b/src/Plugins/BotSharp.Plugin.KnowledgeBase/Services/KnowledgeService.Vector.cs @@ -1,6 +1,6 @@ using BotSharp.Abstraction.Files; using BotSharp.Abstraction.VectorStorage.Enums; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using BotSharp.Core.Infrastructures; namespace BotSharp.Plugin.KnowledgeBase.Services; diff --git a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs index eb83ca0e..40f6d236 100644 --- a/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs +++ b/src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs @@ -110,6 +110,13 @@ public class QdrantDb : IVectorDb if (details == null) return null; + var payloadSchema = details.PayloadSchema?.Select(x => new PayloadSchemaDetail + { + FieldName = x.Key, + FieldDataType = x.Value.DataType.ToString().ToLowerInvariant(), + DataCount = x.Value.Points + })?.ToList() ?? []; + return new VectorCollectionDetails { Status = details.Status.ToString(), @@ -128,7 +135,8 @@ public class QdrantDb : IVectorDb }, VectorsCount = details.VectorsCount, IndexedVectorsCount = details.IndexedVectorsCount, - PointsCount = details.PointsCount + PointsCount = details.PointsCount, + PayloadSchema = payloadSchema }; } #endregion