Skip to content

Commit c43892e

Browse files
Update aspnetcore/tutorials/ai-powered-group-chat/ai-powered-group-chat.md
Co-authored-by: David Pine <[email protected]>
1 parent dabdfd6 commit c43892e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

aspnetcore/tutorials/ai-powered-group-chat/ai-powered-group-chat.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ The `CompleteChatStreamingAsync()` method streams responses from OpenAI incremen
8282
The code uses a `StringBuilder` to accumulate the AI's response. It checks the length of the buffered content and sends it to the clients when it exceeds a certain threshold (e.g., 20 characters). This approach ensures that users see the AI’s response as it forms, mimicking a human-like typing effect.
8383
```csharp
8484
totalCompletion.Append(content);
85+
8586
if (totalCompletion.Length - lastSentTokenLength > 20)
8687
{
87-
await Clients.Group(groupName).SendAsync("newMessageWithId", "ChatGPT", id, totalCompletion.ToString());
88+
await Clients.Group(groupName).SendAsync(
89+
"newMessageWithId",
90+
"ChatGPT",
91+
id,
92+
totalCompletion.ToString());
93+
8894
lastSentTokenLength = totalCompletion.Length;
8995
}
9096
```

0 commit comments

Comments
 (0)