diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs index 533020f0..f5c7d76c 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.Summary.cs @@ -22,6 +22,8 @@ public partial class ConversationService if (dialogs.IsNullOrEmpty()) continue; var content = GetConversationContent(dialogs); + if (string.IsNullOrEmpty(content)) continue; + contents.Add(content); } @@ -95,14 +97,16 @@ public partial class ConversationService foreach (var dialog in dialogs.TakeLast(maxDialogCount)) { var role = dialog.Role; - if (role != AgentRole.User) - { - role = AgentRole.Assistant; - } + if (role != AgentRole.User && role != AgentRole.Assistant) continue; conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n"; } + if (string.IsNullOrEmpty(conversation)) + { + return string.Empty; + } + return conversation + "\r\n"; } } diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs index aba09f52..c8f573a6 100644 --- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs +++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/ConversationController.cs @@ -30,7 +30,6 @@ public class ConversationController : ControllerBase { AgentId = agentId, Channel = ConversationChannel.OpenAPI, - UserId = _user.Id, TaskId = config.TaskId }; conv = await service.NewConversation(conv); diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs index 8c4c43b9..7d47a98c 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs @@ -1,5 +1,6 @@ using BotSharp.Abstraction.Plugins.Models; using BotSharp.Abstraction.Repositories.Enums; +using BotSharp.Abstraction.Users.Enums; using BotSharp.Plugin.MongoStorage.Repository; namespace BotSharp.Plugin.MongoStorage; @@ -34,7 +35,10 @@ public class MongoStoragePlugin : IBotSharpPlugin public bool AttachMenu(List menu) { var section = menu.First(x => x.Label == "Apps"); - menu.Add(new PluginMenuDef("MongoDB", icon: "bx bx-data", link: "page/mongodb", weight: section.Weight + 10)); + menu.Add(new PluginMenuDef("MongoDB", icon: "bx bx-data", link: "page/mongodb", weight: section.Weight + 10) + { + Roles = new List { UserRole.Admin } + }); return true; } }