Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva committed Mar 29, 2023
1 parent 0ca4e1c commit e08b9b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions samples/ChatGptBlazor.Wasm/Components/ChatGptStream.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}

Expand Down

0 comments on commit e08b9b2

Please sign in to comment.