From e08b9b27d9b762bd911b9ae2ebea08c3954d58fe Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Wed, 29 Mar 2023 10:45:17 +0200 Subject: [PATCH] Small refactoring --- samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor b/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor index f83be77..4d73032 100644 --- a/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor +++ b/samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor @@ -80,11 +80,12 @@ isAsking = true; messages.Add(new ChatEntry { Sender = ChatGptRoles.User, Content = message! }); - var responseMessage = new ChatEntry { Sender = ChatGptRoles.Assistant, Content = string.Empty }; var responseStream = chatGptClient.AskStreamAsync(conversationId, message!); + message = string.Empty; + await Task.Delay(500); messages.Add(responseMessage); @@ -94,9 +95,10 @@ await foreach (var delta in responseStream.AsDeltas()) { responseMessage.Content += delta; - await Task.Delay(80); + await Task.Delay(80); StateHasChanged(); + await jsRuntime.InvokeVoidAsync(@"scrollIntoView", anchor); }