diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.cs index c810790e..4a5ac778 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.cs @@ -12,7 +12,7 @@ public partial class ConversationService : IConversationService private readonly IConversationStorage _storage; private readonly IConversationStateService _state; private string _conversationId; - private const string AIAssistant = "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a"; + private const string AIAssistant = BuiltInAgentId.AIAssistant; public string ConversationId => _conversationId; diff --git a/src/Infrastructure/BotSharp.Core/Translation/TranslationResponseHook.cs b/src/Infrastructure/BotSharp.Core/Translation/TranslationResponseHook.cs index 755aa110..3df585f2 100644 --- a/src/Infrastructure/BotSharp.Core/Translation/TranslationResponseHook.cs +++ b/src/Infrastructure/BotSharp.Core/Translation/TranslationResponseHook.cs @@ -11,7 +11,7 @@ namespace BotSharp.Logger.Hooks { private readonly IServiceProvider _services; private readonly IConversationStateService _states; - private const string AIAssistant = "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a"; + private const string AIAssistant = BuiltInAgentId.AIAssistant; public TranslationResponseHook(IServiceProvider services, IConversationStateService states) diff --git a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs index 99bb1937..5b699b51 100644 --- a/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs +++ b/src/Plugins/BotSharp.Plugin.ChatHub/Hooks/StreamingLogHook.cs @@ -1,9 +1,6 @@ using Microsoft.AspNetCore.SignalR; using System.Text.Encodings.Web; using System.Text.Unicode; -using Newtonsoft.Json.Linq; -using JsonConvert = Newtonsoft.Json.JsonConvert; -using JsonSerializerSettings = Newtonsoft.Json.JsonSerializerSettings; namespace BotSharp.Plugin.ChatHub.Hooks; diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailRequestFn.cs b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailRequestFn.cs index 84be6e16..9f8406a8 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailRequestFn.cs +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/Functions/HandleEmailRequestFn.cs @@ -95,7 +95,7 @@ public class HandleEmailRequestFn : IFunctionCallback { var promptFiles = files.Select((x, idx) => { - return $"id: {idx + 1}, file_name: {x.FileName}.{x.FileType}, author: {x.FileSource}, content_type: {x.ContentType}"; + return $"id: {idx + 1}, file_name: {x.FileName}.{x.FileType}, content_type: {x.ContentType}, author: {x.FileSource}"; }).ToList(); var prompt = db.GetAgentTemplate(BuiltInAgentId.UtilityAssistant, "select_attachment_prompt"); prompt = render.Render(prompt, new Dictionary @@ -113,7 +113,8 @@ public class HandleEmailRequestFn : IFunctionCallback var provider = llmProviderService.GetProviders().FirstOrDefault(x => x == "openai"); var model = llmProviderService.GetProviderModel(provider: provider, id: "gpt-4"); var completion = CompletionProvider.GetChatCompletion(_services, provider: provider, model: model.Name); - var response = await completion.GetChatCompletions(agent, dialogs); + var latest = dialogs.LastOrDefault(); + var response = await completion.GetChatCompletions(agent, new List { latest }); var content = response?.Content ?? string.Empty; var selecteds = JsonSerializer.Deserialize(content); var fids = selecteds?.Selecteds ?? new List(); diff --git a/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_attachment_prompt.liquid b/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_attachment_prompt.liquid index f96e286a..f4295baa 100644 --- a/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_attachment_prompt.liquid +++ b/src/Plugins/BotSharp.Plugin.EmailHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_attachment_prompt.liquid @@ -9,12 +9,12 @@ Here is the JSON format to use: "selected_ids": a list of id selected from the [FILES] section } -Suppose there are 4 files: +Suppose there are four files: -id: 1, file_name: example_file.jpg, author: user, content_type: image/jpeg -id: 2, file_name: example_file.pdf, author: user, content_type: application/pdf -id: 3, file_name: example_file.png, author: bot, content_type: image/png -id: 4, file_name: example_file.png, author: bot, content_type: image/png +id: 1, file_name: example_file.jpg, content_type: image/jpeg, author: user +id: 2, file_name: example_file.pdf, content_type: application/pdf, author: user +id: 3, file_name: example_file.png, content_type: image/png, author: bot +id: 4, file_name: example_file.png, content_type: image/png, author: bot ===== Example 1: diff --git a/src/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_edit_image_prompt.liquid b/src/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_edit_image_prompt.liquid index 4d050563..9e67faad 100644 --- a/src/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_edit_image_prompt.liquid +++ b/src/Plugins/BotSharp.Plugin.FileHandler/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/templates/select_edit_image_prompt.liquid @@ -1,5 +1,4 @@ Please take a look at the images in the [IMAGES] section from the conversation and select ONLY one image based on the conversation with user. -Your response must be an interger number. ** Ensure the output is only in JSON format without any additional text. ** You may need to look at the image_name as a reference to find the correct image id. @@ -10,7 +9,7 @@ Here is the JSON format to use: } -Suppose there are three images: +Suppose there are four images: id: 1, image_name: example_image_a.png id: 2, image_name: example_image_b.png diff --git a/tests/BotSharp.Plugin.PizzaBot/Hooks/PizzaBotAgentHook.cs b/tests/BotSharp.Plugin.PizzaBot/Hooks/PizzaBotAgentHook.cs index 76ac568b..ff2eb8f6 100644 --- a/tests/BotSharp.Plugin.PizzaBot/Hooks/PizzaBotAgentHook.cs +++ b/tests/BotSharp.Plugin.PizzaBot/Hooks/PizzaBotAgentHook.cs @@ -1,10 +1,11 @@ using BotSharp.Abstraction.Agents; +using BotSharp.Abstraction.Agents.Enums; namespace BotSharp.Plugin.PizzaBot.Hooks; public class PizzaBotAgentHook : AgentHookBase { - public override string SelfId => "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a"; + public override string SelfId => BuiltInAgentId.AIAssistant; public PizzaBotAgentHook(IServiceProvider services, AgentSettings settings) : base(services, settings)