Skip to content

Commit

Permalink
Extract processing time calculation into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhulen committed Dec 23, 2024
1 parent 1588e6b commit 604b685
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/dotnet/Core/Services/CoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public async Task<LongRunningOperation> GetCompletionOperationStatus(string inst
PropertyValues = new Dictionary<string, object?>
{
{ "/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 }
}
}
};
Expand All @@ -294,7 +295,9 @@ public async Task<LongRunningOperation> 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
};
Expand Down Expand Up @@ -330,7 +333,9 @@ public async Task<LongRunningOperation> 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;
Expand All @@ -347,7 +352,8 @@ public async Task<LongRunningOperation> 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
};
Expand Down
6 changes: 6 additions & 0 deletions src/ui/UserPortal/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 604b685

Please sign in to comment.