From ca1789111bca7ef792d734b0b8f9c12f0a88d9c3 Mon Sep 17 00:00:00 2001 From: Joanna Ren <101223@smsassist.com> Date: Tue, 12 Nov 2024 22:08:53 -0600 Subject: [PATCH 1/5] minor update --- .../BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs | 3 --- .../BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs b/src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs index 664ad7b9..84378158 100644 --- a/src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs +++ b/src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs @@ -96,9 +96,6 @@ public class PrimaryStagePlanFn : IFunctionCallback var conv = _services.GetRequiredService(); var wholeDialogs = conv.GetDialogHistory(); - // Append text - wholeDialogs.Last().Content += "\n\nYou must analyze the table description to infer the table relations. Only output the JSON result."; - var completion = CompletionProvider.GetChatCompletion(_services, provider: plannerAgent.LlmConfig.Provider, model: plannerAgent.LlmConfig.Model); diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs index 8778b5a5..a1c4dca9 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/Functions/SqlValidateFn.cs @@ -74,7 +74,7 @@ public class SqlValidateFn : IFunctionCallback Message = "Correct SQL Statement", Data = new Dictionary { - { "original_sql", validateSql }, + { "original_sql", sql }, { "error_message", ex.Message }, { "table_structure", ddl } } From 93b15408be68a09ed4b80abed757349e9b27c93d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Tue, 12 Nov 2024 23:57:05 -0500 Subject: [PATCH 2/5] Update Microsoft.Extensions.AI.Abstractions to 9.0.0-preview.9.24556.5 --- .../BotSharp.Plugin.MicrosoftExtensionsAI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/BotSharp.Plugin.MicrosoftExtensionsAI.csproj b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/BotSharp.Plugin.MicrosoftExtensionsAI.csproj index 53518b38..9262828f 100644 --- a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/BotSharp.Plugin.MicrosoftExtensionsAI.csproj +++ b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/BotSharp.Plugin.MicrosoftExtensionsAI.csproj @@ -12,7 +12,7 @@ - + From b17db8a86fd27a977629ede35acbfba60811ffba Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 13 Nov 2024 09:34:21 -0600 Subject: [PATCH 3/5] Fix Twilio CallbackPath path --- .../Controllers/TwilioVoiceController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs index dd3db295..34807ad9 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs @@ -48,7 +48,7 @@ public class TwilioVoiceController : TwilioController var instruction = new ConversationalVoiceResponse { SpeechPaths = ["twilio/welcome.mp3"], - CallbackPath = $"twilio/voice/{request.ConversationId}/receive/0?{GenerateStatesParameter(request.States)}", + CallbackPath = $"twilio/voice/{request.ConversationId}/receive/0", ActionOnEmptyResult = true, Timeout = 2 }; @@ -60,6 +60,8 @@ public class TwilioVoiceController : TwilioController OnlyOnce = true }); + instruction.CallbackPath = $"{instruction.CallbackPath}?{GenerateStatesParameter(request.States)}"; + var twilio = _services.GetRequiredService(); if (string.IsNullOrWhiteSpace(request.Intent)) { From deb01d45bb614cec83b1bfa0239521257bc23c0b Mon Sep 17 00:00:00 2001 From: Haiping Date: Wed, 13 Nov 2024 10:54:59 -0600 Subject: [PATCH 4/5] Update verify_dictionary_term.json --- .../functions/verify_dictionary_term.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.SqlDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/verify_dictionary_term.json b/src/Plugins/BotSharp.Plugin.SqlDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/verify_dictionary_term.json index 0e79a2fe..871210a2 100644 --- a/src/Plugins/BotSharp.Plugin.SqlDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/verify_dictionary_term.json +++ b/src/Plugins/BotSharp.Plugin.SqlDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/verify_dictionary_term.json @@ -18,13 +18,13 @@ }, "tables": { "type": "array", - "description": "all related dictionary tables", + "description": "all related dictionary tables must be from related knowledge in the context", "items": { "type": "string", - "description": "table name" + "description": "table name from related knowledge in the context" } } }, "required": [ "sql_statement", "reason", "tables" ] } -} \ No newline at end of file +} From 8baff7156e69b83f65c546e3310f8a3d91e0a120 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 13 Nov 2024 15:09:39 -0600 Subject: [PATCH 5/5] Twilio optimize --- .../Controllers/TwilioVoiceController.cs | 15 +++++---------- .../Services/TwilioService.cs | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs index 34807ad9..4f91b81b 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Controllers/TwilioVoiceController.cs @@ -43,14 +43,10 @@ public class TwilioVoiceController : TwilioController } VoiceResponse response = null; - request.ConversationId = $"TwilioVoice_{request.CallSid}"; - var instruction = new ConversationalVoiceResponse { SpeechPaths = ["twilio/welcome.mp3"], - CallbackPath = $"twilio/voice/{request.ConversationId}/receive/0", - ActionOnEmptyResult = true, - Timeout = 2 + ActionOnEmptyResult = true }; await HookEmitter.Emit(_services, async hook => { @@ -60,7 +56,8 @@ public class TwilioVoiceController : TwilioController OnlyOnce = true }); - instruction.CallbackPath = $"{instruction.CallbackPath}?{GenerateStatesParameter(request.States)}"; + request.ConversationId = $"TwilioVoice_{request.CallSid}"; + instruction.CallbackPath = $"twilio/voice/{request.ConversationId}/receive/0?{GenerateStatesParameter(request.States)}"; var twilio = _services.GetRequiredService(); if (string.IsNullOrWhiteSpace(request.Intent)) @@ -109,7 +106,6 @@ public class TwilioVoiceController : TwilioController var twilio = _services.GetRequiredService(); var messageQueue = _services.GetRequiredService(); var sessionManager = _services.GetRequiredService(); - var messages = await sessionManager.RetrieveStagedCallerMessagesAsync(request.ConversationId, request.SeqNum); string text = (request.SpeechResult + "\r\n" + request.Digits).Trim(); @@ -148,7 +144,7 @@ public class TwilioVoiceController : TwilioController else { // keep waiting for user response - if (request.Attempts > 2) + if (request.Attempts > 3) { var instruction = new ConversationalVoiceResponse { @@ -187,7 +183,7 @@ public class TwilioVoiceController : TwilioController ActionOnEmptyResult = true }; - if (request.Attempts == 2) + if (request.Attempts == 3) { instruction.SpeechPaths.Add($"twilio/say-it-again-{Random.Shared.Next(1, 5)}.mp3"); } @@ -220,7 +216,6 @@ public class TwilioVoiceController : TwilioController var sessionManager = _services.GetRequiredService(); var twilio = _services.GetRequiredService(); var fileStorage = _services.GetRequiredService(); - if (request.SpeechResult != null) { await sessionManager.StageCallerMessageAsync(request.ConversationId, nextSeqNum, request.SpeechResult); diff --git a/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs b/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs index ebb59229..8acbc9f4 100644 --- a/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs +++ b/src/Plugins/BotSharp.Plugin.Twilio/Services/TwilioService.cs @@ -115,7 +115,7 @@ public class TwilioService }, Action = new Uri($"{_settings.CallbackHost}/{conversationalVoiceResponse.CallbackPath}"), SpeechModel = Gather.SpeechModelEnum.PhoneCall, - SpeechTimeout = conversationalVoiceResponse.Timeout > 0 ? conversationalVoiceResponse.Timeout.ToString() : "3", + SpeechTimeout = "auto", // conversationalVoiceResponse.Timeout > 0 ? conversationalVoiceResponse.Timeout.ToString() : "3", Timeout = conversationalVoiceResponse.Timeout > 0 ? conversationalVoiceResponse.Timeout : 3, ActionOnEmptyResult = conversationalVoiceResponse.ActionOnEmptyResult };