From 604b6851607bf403786376c3a9e9a960129b1b80 Mon Sep 17 00:00:00 2001 From: joelhulen Date: Mon, 23 Dec 2024 12:05:04 -0500 Subject: [PATCH] Extract processing time calculation into a method --- src/dotnet/Core/Services/CoreService.cs | 14 ++++++++++---- src/ui/UserPortal/stores/appStore.ts | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/dotnet/Core/Services/CoreService.cs b/src/dotnet/Core/Services/CoreService.cs index 20b016640..597b2150f 100644 --- a/src/dotnet/Core/Services/CoreService.cs +++ b/src/dotnet/Core/Services/CoreService.cs @@ -276,7 +276,8 @@ public async Task GetCompletionOperationStatus(string inst PropertyValues = new Dictionary { { "/status", OperationStatus.Failed }, - { "/text", "The completion operation has exceeded the maximum time allowed." } + { "/text", "The completion operation has exceeded the maximum time allowed." }, + { "/timeStamp", DateTime.UtcNow } } } }; @@ -294,7 +295,9 @@ public async Task GetCompletionOperationStatus(string inst { OperationId = operationId, Status = OperationStatus.Failed, - Text = "The completion operation has exceeded the maximum time allowed." + Text = "The completion operation has exceeded the maximum time allowed.", + TimeStamp = DateTime.UtcNow, + SenderDisplayName = operationContext.AgentName }, Status = OperationStatus.Failed }; @@ -330,7 +333,9 @@ public async Task GetCompletionOperationStatus(string inst { OperationId = operationId, Status = operationStatus.Status, - Text = operationStatus.StatusMessage ?? "The completion operation is in progress." + Text = operationStatus.StatusMessage ?? "The completion operation is in progress.", + TimeStamp = DateTime.UtcNow, + SenderDisplayName = operationContext.AgentName }; return operationStatus; @@ -347,7 +352,8 @@ public async Task GetCompletionOperationStatus(string inst { OperationId = operationId, Status = OperationStatus.Failed, - Text = "Could not retrieve the status of the operation due to an internal error." + Text = "Could not retrieve the status of the operation due to an internal error.", + TimeStamp = DateTime.UtcNow }, Status = OperationStatus.Failed }; diff --git a/src/ui/UserPortal/stores/appStore.ts b/src/ui/UserPortal/stores/appStore.ts index 05cced0a8..fc02e780c 100644 --- a/src/ui/UserPortal/stores/appStore.ts +++ b/src/ui/UserPortal/stores/appStore.ts @@ -298,6 +298,10 @@ export const useAppStore = defineStore('app', { } } + this.calculateMessageProcessingTime(); + }, + + calculateMessageProcessingTime() { // Calculate the processing time for each message this.currentMessages.forEach((message, index) => { if (message.sender === 'Agent' && this.currentMessages[index - 1]?.sender === 'User') { @@ -484,6 +488,8 @@ export const useAppStore = defineStore('app', { userMessage.tokens = statusResponse.prompt_tokens; } + this.calculateMessageProcessingTime(); + if (updatedMessage.status === 'Completed' || updatedMessage.status === 'Failed') { this.stopPolling(sessionId); }