Skip to content

Commit

Permalink
fix string +=
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzeyu91 committed Jul 1, 2024
1 parent 7558d3f commit 22d9909
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/AntSK/Pages/ChatPage/Components/ChatView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text;

namespace AntSK.Pages.ChatPage.Components
{
Expand Down Expand Up @@ -324,11 +325,11 @@ private async Task SendKms(string questions, ChatHistory history, Apps app, stri
};
MessageList.Add(info);
var chatResult = _chatService.SendKmsByAppAsync(app, questions, history, filePath, _relevantSources);
var rawContent = string.Empty;
StringBuilder rawContent = new StringBuilder();
await foreach (var content in chatResult)
{
rawContent+=content.ConvertToString();
info.Context=Markdown.ToHtml(rawContent);
rawContent.Append(content.ConvertToString());
info.Context = Markdown.ToHtml(rawContent.ToString());
//await Task.Delay(50);
await InvokeAsync(StateHasChanged);
}
Expand All @@ -346,12 +347,12 @@ private async Task SendChat(ChatHistory history, Apps app)
{
Chats info = null;
var chatResult = _chatService.SendChatByAppAsync(app, history);
var rawContent=string.Empty;
StringBuilder rawContent = new StringBuilder();
await foreach (var content in chatResult)
{
if (info == null)
{
rawContent=content.ConvertToString();
rawContent.Append(content.ConvertToString());
info = new Chats();
info.Id = Guid.NewGuid().ToString();
info.UserName = _userName;
Expand All @@ -363,9 +364,9 @@ private async Task SendChat(ChatHistory history, Apps app)
}
else
{
rawContent+=content.ConvertToString();
rawContent.Append(content.ConvertToString());
}
info.Context = Markdown.ToHtml(rawContent);
info.Context = Markdown.ToHtml(rawContent.ToString());
//await Task.Delay(50);
await InvokeAsync(StateHasChanged);
}
Expand Down

0 comments on commit 22d9909

Please sign in to comment.