From 41da7d6627830f56497f96690d5b489c1c0a6b8e Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 10 May 2024 17:48:55 -0500 Subject: [PATCH 1/4] Remove language detection from router. --- .../templates/planner_prompt.naive.liquid | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.naive.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.naive.liquid index 5177a002..3fa0a7f7 100644 --- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.naive.liquid +++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.naive.liquid @@ -9,5 +9,4 @@ Next action agent is inferred based on user lastest response. Expected user goal agent is {{ expected_user_goal_agent }}. {%- else -%} User goal agent is inferred based on user initial request. -{%- endif %} -Detect language based on the overall content in [CONVERSATION] and only include user message. \ No newline at end of file +{%- endif %} \ No newline at end of file From 5699842b49f0c0eedcc286114c8b9fe977d80939 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 10 May 2024 18:27:41 -0500 Subject: [PATCH 2/4] Save payload only when it's not empty. --- .../Conversations/Services/ConversationService.SendMessage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index 489e400e..d6940fe1 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -52,9 +52,9 @@ public partial class ConversationService message.Files?.Clear(); // Save payload - if (replyMessage != null) + if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload)) { - message.Payload = string.IsNullOrEmpty(replyMessage.Payload) ? message.Content : replyMessage.Payload; + message.Payload = replyMessage.Payload; } // Before chat completion hook From 07dc85375e72e17eaeef84cdeee814a3b2706edf Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 10 May 2024 21:31:16 -0500 Subject: [PATCH 3/4] Add Description to ElementButton --- .../Messaging/Models/RichContent/ElementButton.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs index cd3d9da6..daf3de65 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs @@ -8,13 +8,18 @@ public class ElementButton public string Type { get; set; } = "web_url"; [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string Url { get; set; } + public string? Url { get; set; } [Translate] public string Title { get; set; } = string.Empty; + [JsonPropertyName("description")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string Payload { get; set; } + [Translate] + public string? Description { get; set; } + + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? Payload { get; set; } [JsonPropertyName("is_primary")] public bool IsPrimary { get; set; } From e620d5d16129630aa05bb14503a9222be0cc1f98 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 10 May 2024 21:59:51 -0500 Subject: [PATCH 4/4] Not set language if exists. --- .../BotSharp.Core/Translation/TranslationService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs index b18c7ab1..07c2c973 100644 --- a/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs +++ b/src/Infrastructure/BotSharp.Core/Translation/TranslationService.cs @@ -61,9 +61,11 @@ public class TranslationService : ITranslationService { // Override language if it's Unknown, it's used to output the corresponding language. var states = _services.GetRequiredService(); - var inputLanguage = string.IsNullOrEmpty(translatedStringList.InputLanguage) ? LanguageType.ENGLISH : translatedStringList.InputLanguage; - var languageState = states.GetState("language", inputLanguage); - states.SetState("language", languageState, activeRounds: 1); + if (!states.ContainsState("language")) + { + var inputLanguage = string.IsNullOrEmpty(translatedStringList.InputLanguage) ? LanguageType.ENGLISH : translatedStringList.InputLanguage; + states.SetState("language", inputLanguage, activeRounds: 1); + } var translatedTexts = translatedStringList.Texts; var map = new Dictionary();