From 266ef113abf9014b5a98676b2bff08f043079112 Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 16:31:04 -0400 Subject: [PATCH 1/6] Added logging durations for all semantic kernal calls. (cherry picked from commit 78dc55dbe3b786267fc1c2b94b1273a5b7303851) # Conflicts: # Util/CallLogsChecker.cs --- Util/CallLogsChecker.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Util/CallLogsChecker.cs b/Util/CallLogsChecker.cs index 93bbfcd..c59bc26 100644 --- a/Util/CallLogsChecker.cs +++ b/Util/CallLogsChecker.cs @@ -132,6 +132,7 @@ public async Task CheckVerificationIntentAsync(Kernel kernel, string per KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + var startTime = DateTime.UtcNow; try { // KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } }; @@ -142,6 +143,10 @@ public async Task CheckVerificationIntentAsync(Kernel kernel, string per { Console.WriteLine(ex); } + finally + { + Console.WriteLine($"Duration of Semantic Kernel for CheckVerificationIntentAsync: { DateTime.UtcNow - startTime } "); + } return result ?? ""; } @@ -156,6 +161,7 @@ public async Task CheckFraudIntentAsync(Kernel kernel, string personid, KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + var startTime = DateTime.UtcNow; try { // KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } }; @@ -166,6 +172,10 @@ public async Task CheckFraudIntentAsync(Kernel kernel, string personid, { Console.WriteLine(ex); } + finally + { + Console.WriteLine($"Duration of Semantic Kernel for CheckFraudIntentAsync: {DateTime.UtcNow - startTime} "); + } return result ?? ""; } @@ -180,6 +190,7 @@ public async Task CheckActionConclusionAsync(Kernel kernel, string perso KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + var startTime = DateTime.UtcNow; try { // KernelArguments arguments = new(new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" }) { { "query", query } }; @@ -190,6 +201,10 @@ public async Task CheckActionConclusionAsync(Kernel kernel, string perso { Console.WriteLine(ex); } + finally + { + Console.WriteLine($"Duration of Semantic Kernel for CheckActionConclusionAsync: {DateTime.UtcNow - startTime} "); + } return result ?? ""; } } From 3b6e64077016a7af70d3d0dd0c7a31e3d3e21c84 Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 16:41:52 -0400 Subject: [PATCH 2/6] Spacing out the AI prompts to be more readable. (cherry picked from commit 6d1734f13389ac8c8a2a0fb7526eb93bd1e71f27) --- Util/CallLogsChecker.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Util/CallLogsChecker.cs b/Util/CallLogsChecker.cs index c59bc26..b0df33c 100644 --- a/Util/CallLogsChecker.cs +++ b/Util/CallLogsChecker.cs @@ -17,8 +17,14 @@ internal class CallLogChecker private string _promptVerificationConclusion = @"PersonID: {{$personid}} {{$query}} - Return the Verification Conclusion of the query. The Verification Conclusion must be in the format of JSON that consists of PersonID, ActivityRelatedTo, FormOfAuthentication, Phone Number properties. The phone number will contain 10 digits and may or may not have dashes. If there are multiple numbers listed, identify the most recent, updated phone number. If there is no phone number, return 'no phone number'. - If ActivityRelatedTo is not 'Inbound Call' VerificationCompleted should be set to 'No'. ActivityRelatedTo must be set to 'Inbound Call' and FormOfAuthentication must be 'KBA' or 'ID Verification' or 'One Time Passcode' before VerficationsCompleted can be set to 'Yes', otherwise VerficationsCompleted must be set to 'No'. The JSON format should be: + Return the Verification Conclusion of the query. + The Verification Conclusion must be in the format of JSON that consists of PersonID, ActivityRelatedTo, FormOfAuthentication, Phone Number properties. + The phone number will contain 10 digits and may or may not have dashes. + If there are multiple numbers listed, identify the most recent, updated phone number. + If there is no phone number, return 'no phone number'. + If ActivityRelatedTo is not 'Inbound Call' VerificationCompleted should be set to 'No'. + ActivityRelatedTo must be set to 'Inbound Call' and FormOfAuthentication must be 'KBA' or 'ID Verification' or 'One Time Passcode' before VerficationsCompleted can be set to 'Yes' + , otherwise VerficationsCompleted must be set to 'No'. The JSON format should be: [JSON] { 'PersonID': '12345', @@ -61,7 +67,12 @@ [JSON END] private string _promptFraudConclusion = @"PersonID: {{$personid}} {{$query}} - Return the Fraud Conclusion intent of the query. The Fraud Conclusion must be in the format of JSON that consists of FraudConclusionNotes, FraudConclusionType, Recommendation properties. The FraudConclusionNotes should a short summary based on your review of the query. The FraudConclusionType should be either 'No Fraud Detected' or 'Possible Account Takeover'. The Recommendation should be your recommendations for futher action based on your conclusions. The JSON format should be: + Return the Fraud Conclusion intent of the query. + The Fraud Conclusion must be in the format of JSON that consists of FraudConclusionNotes, FraudConclusionType, Recommendation properties. + The FraudConclusionNotes should a short summary based on your review of the query. + The FraudConclusionType should be either 'No Fraud Detected' or 'Possible Account Takeover'. + The Recommendation should be your recommendations for futher action based on your conclusions. + The JSON format should be: [JSON] { 'PersonID': '12345', @@ -84,7 +95,10 @@ [JSON END] private string _promptActionConclusion = @"PersonID: {{$personid}} {{$query}} - Return the Action Conclusion intent of the query. The Acton Conclusion must be in the format of JSON that consists of PersonID, CallerAuthenticated, FormOfAuthentication, ThirdPartyInvolved, WasCallTransferred, PhoneUpdateFrom, PhoneUpdatedTo, PhoneChanged, AddressChanged, AddressUpdateFrom, AddressUpdateTo properties. The JSON format should be: + Return the Action Conclusion intent of the query. + The Acton Conclusion must be in the format of JSON that consists of + PersonID, CallerAuthenticated, FormOfAuthentication, ThirdPartyInvolved, WasCallTransferred, PhoneUpdateFrom, PhoneUpdatedTo, PhoneChanged, AddressChanged, AddressUpdateFrom, AddressUpdateTo properties. + The JSON format should be: [JSON] { From 9345e394292b68d81c4ed9612d6b74ae61fcc379 Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 19:15:29 -0400 Subject: [PATCH 3/6] Added timers to let user know that we are still waiting for the Semantic kernel if it's longer than 10 seconds. (cherry picked from commit f8579eaff77902e55cd3089aeacff518e3a74d1f) --- Util/CallLogsChecker.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Util/CallLogsChecker.cs b/Util/CallLogsChecker.cs index b0df33c..1f1340d 100644 --- a/Util/CallLogsChecker.cs +++ b/Util/CallLogsChecker.cs @@ -146,6 +146,8 @@ public async Task CheckVerificationIntentAsync(Kernel kernel, string per KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + timerCallback = new TimerCallback(OnTimerElapsed); + var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000); var startTime = DateTime.UtcNow; try { @@ -155,10 +157,12 @@ public async Task CheckVerificationIntentAsync(Kernel kernel, string per } catch (Exception ex) { + timer.Dispose(); Console.WriteLine(ex); } finally { + timer.Dispose(); Console.WriteLine($"Duration of Semantic Kernel for CheckVerificationIntentAsync: { DateTime.UtcNow - startTime } "); } return result ?? ""; @@ -175,6 +179,8 @@ public async Task CheckFraudIntentAsync(Kernel kernel, string personid, KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + timerCallback = new TimerCallback(OnTimerElapsed); + var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000); var startTime = DateTime.UtcNow; try { @@ -188,6 +194,7 @@ public async Task CheckFraudIntentAsync(Kernel kernel, string personid, } finally { + timer.Dispose(); Console.WriteLine($"Duration of Semantic Kernel for CheckFraudIntentAsync: {DateTime.UtcNow - startTime} "); } return result ?? ""; @@ -204,6 +211,9 @@ public async Task CheckActionConclusionAsync(Kernel kernel, string perso KernelArguments arguments2 = new(executionSettings) { { "query", query }, { "personid", personid } }; string result = ""; + timerCallback = new TimerCallback(OnTimerElapsed); + var timer = new Timer(timerCallback, null, 10 * 1000, 10 * 1000); + var startTime = DateTime.UtcNow; try { @@ -217,10 +227,17 @@ public async Task CheckActionConclusionAsync(Kernel kernel, string perso } finally { + timer.Dispose(); Console.WriteLine($"Duration of Semantic Kernel for CheckActionConclusionAsync: {DateTime.UtcNow - startTime} "); } return result ?? ""; } + + static TimerCallback timerCallback; + static void OnTimerElapsed(object state) + { + Console.WriteLine("Still working..."); + } } } From 556775636d4471bda69883e16b22897dff1d9f2b Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 19:42:10 -0400 Subject: [PATCH 4/6] Added console output if there are exceptions, otherwise we never know. (cherry picked from commit c1e7ea6b32f6b24333be8d2dcd5c5b76205bd6d7) --- Controllers/ProcessRunningController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Controllers/ProcessRunningController.cs b/Controllers/ProcessRunningController.cs index 139edd2..08e2b8d 100644 --- a/Controllers/ProcessRunningController.cs +++ b/Controllers/ProcessRunningController.cs @@ -77,6 +77,7 @@ public async Task ProcessRunner() } catch (Exception ex) { + Console.WriteLine(ex.ToString()); return BadRequest($"An error occured: {ex.Message}"); } } @@ -106,6 +107,7 @@ public ActionResult SendFileDetails([FromBody] UploadedFilesRequest filesrequest } catch (Exception ex) { + Console.WriteLine(ex.ToString()); return BadRequest($"An error occured: {ex.Message}"); } } From 5006fa80a1280ee778c49dc21fba2f7b0fb34fd6 Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 19:42:44 -0400 Subject: [PATCH 5/6] Quoted the FraudConclusion.Recommendation field so that commas don't make it look like other fields. (cherry picked from commit cac52f1489fba4d7024b42b2e9055a2c6045497f) --- Models/Reporting/FraudConclusion.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Models/Reporting/FraudConclusion.cs b/Models/Reporting/FraudConclusion.cs index ee8a61d..bac15f1 100644 --- a/Models/Reporting/FraudConclusion.cs +++ b/Models/Reporting/FraudConclusion.cs @@ -8,6 +8,7 @@ public class FraudConclusion public string? PersonID { get; set; } public string? FraudConclusionNote { get; set; } public string? FraudConclusionType { get; set; } + [FieldQuoted] public string? Recommendation { get; set; } } From 17717b3f28b19ef0af83a80bd7e241c148e690e2 Mon Sep 17 00:00:00 2001 From: Chris Blaszczynski Date: Wed, 8 May 2024 19:52:18 -0400 Subject: [PATCH 6/6] Quoting Address fields in ActionConclusion. (cherry picked from commit 50260499d27b18a46f5a54d8e838389367cd29ac) --- Models/Reporting/ActionConclusion.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Models/Reporting/ActionConclusion.cs b/Models/Reporting/ActionConclusion.cs index c4051b3..a3ac90b 100644 --- a/Models/Reporting/ActionConclusion.cs +++ b/Models/Reporting/ActionConclusion.cs @@ -14,7 +14,9 @@ public class ActionConclusion public string? PhoneUpdateTo { get; set; } public string? PhoneChanged { get; set; } public string? AddressChanged { get; set; } + [FieldQuoted] public string? AddressUpdateFrom { get; set; } + [FieldQuoted] public string? AddressUpdateTo { get; set; } } }