diff --git a/src/Infrastructure/BotSharp.Abstraction/Plugins/Models/PluginMenuDef.cs b/src/Infrastructure/BotSharp.Abstraction/Plugins/Models/PluginMenuDef.cs index c387d1ca..8742312d 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Plugins/Models/PluginMenuDef.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Plugins/Models/PluginMenuDef.cs @@ -13,6 +13,9 @@ public class PluginMenuDef(string label, string? link = null, string? icon = nul [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Link { get; set; } = link; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? IFrameUrl { get; set; } + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public bool? IsHeader { get; set; } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogBetaDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs similarity index 88% rename from src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogBetaDocument.cs rename to src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs index 4f70ad60..91bcdc68 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogBetaDocument.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/InstructionLogDocument.cs @@ -2,7 +2,7 @@ using BotSharp.Abstraction.Loggers.Models; namespace BotSharp.Plugin.MongoStorage.Collections; -public class InstructionLogBetaDocument : MongoBase +public class InstructionLogDocument : MongoBase { public string? AgentId { get; set; } public string Provider { get; set; } = default!; @@ -15,9 +15,9 @@ public class InstructionLogBetaDocument : MongoBase public Dictionary States { get; set; } = new(); public DateTime CreatedTime { get; set; } - public static InstructionLogBetaDocument ToMongoModel(InstructionLogModel log) + public static InstructionLogDocument ToMongoModel(InstructionLogModel log) { - return new InstructionLogBetaDocument + return new InstructionLogDocument { AgentId = log.AgentId, Provider = log.Provider, @@ -31,7 +31,7 @@ public class InstructionLogBetaDocument : MongoBase }; } - public static InstructionLogModel ToDomainModel(InstructionLogBetaDocument log) + public static InstructionLogModel ToDomainModel(InstructionLogDocument log) { return new InstructionLogModel { diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoDbContext.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoDbContext.cs index 277f9e25..73853230 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoDbContext.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoDbContext.cs @@ -115,7 +115,7 @@ public class MongoDbContext { var collection = GetCollectionOrCreate("ConversationContentLogs"); var indexes = collection.Indexes.List().ToList(); - var createTimeIndex = indexes.FirstOrDefault(x => x.GetElement("name").ToString().StartsWith("CreateTime")); + var createTimeIndex = indexes.FirstOrDefault(x => x.GetElement("name").ToString().StartsWith("CreatedTime")); if (createTimeIndex == null) { var indexDef = Builders.IndexKeys.Ascending(x => x.CreatedTime); @@ -128,7 +128,7 @@ public class MongoDbContext { var collection = GetCollectionOrCreate("ConversationStateLogs"); var indexes = collection.Indexes.List().ToList(); - var createTimeIndex = indexes.FirstOrDefault(x => x.GetElement("name").ToString().StartsWith("CreateTime")); + var createTimeIndex = indexes.FirstOrDefault(x => x.GetElement("name").ToString().StartsWith("CreatedTime")); if (createTimeIndex == null) { var indexDef = Builders.IndexKeys.Ascending(x => x.CreatedTime); @@ -136,6 +136,19 @@ public class MongoDbContext } return collection; } + + private IMongoCollection CreateInstructionLogIndex() + { + var collection = GetCollectionOrCreate("InstructionLogs"); + var indexes = collection.Indexes.List().ToList(); + var createTimeIndex = indexes.FirstOrDefault(x => x.GetElement("name").ToString().StartsWith("CreatedTime")); + if (createTimeIndex == null) + { + var indexDef = Builders.IndexKeys.Descending(x => x.CreatedTime); + collection.Indexes.CreateOne(new CreateIndexModel(indexDef)); + } + return collection; + } #endregion #endregion @@ -193,6 +206,6 @@ public class MongoDbContext public IMongoCollection GlobalStatistics => GetCollectionOrCreate("GlobalStatistics"); - public IMongoCollection InstructionLogs - => GetCollectionOrCreate("InstructionLogs"); + public IMongoCollection InstructionLogs + => CreateInstructionLogIndex(); } \ No newline at end of file diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs index 20cca2a7..40da0321 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Log.cs @@ -119,10 +119,10 @@ public partial class MongoRepository { if (logs.IsNullOrEmpty()) return false; - var docs = new List(); + var docs = new List(); foreach (var log in logs) { - var doc = InstructionLogBetaDocument.ToMongoModel(log); + var doc = InstructionLogDocument.ToMongoModel(log); foreach (var pair in log.States) { try @@ -152,8 +152,8 @@ public partial class MongoRepository filter = InstructLogFilter.Empty(); } - var builder = Builders.Filter; - var filters = new List>() { builder.Empty }; + var builder = Builders.Filter; + var filters = new List>() { builder.Empty }; // Filter logs if (!filter.AgentIds.IsNullOrEmpty()) @@ -174,13 +174,13 @@ public partial class MongoRepository } var filterDef = builder.And(filters); - var sortDef = Builders.Sort.Descending(x => x.CreatedTime); + var sortDef = Builders.Sort.Descending(x => x.CreatedTime); var docs = _dc.InstructionLogs.Find(filterDef).Sort(sortDef).Skip(filter.Offset).Limit(filter.Size).ToList(); var count = _dc.InstructionLogs.CountDocuments(filterDef); var logs = docs.Select(x => { - var log = InstructionLogBetaDocument.ToDomainModel(x); + var log = InstructionLogDocument.ToDomainModel(x); log.States = x.States.ToDictionary(p => p.Key, p => { var jsonStr = p.Value.ToJson();