Skip to content

Commit cf4c5c2

Browse files
authored
Merge pull request #1 from DevExpress-Examples/vl_review
Readme and fixes
2 parents cff7546 + 7a9c166 commit cf4c5c2

5 files changed

Lines changed: 244 additions & 175 deletions

File tree

CS/AiGrammarChecker.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageReference Include="DevExpress.Blazor" Version="25.1.*-*" />
1010
<PackageReference Include="DevExpress.AIIntegration.Blazor" Version="25.1.*-*" />
1111
<PackageReference Include="Markdig" Version="0.41.3" />
12-
12+
<PackageReference Include="HtmlSanitizer" Version="9.1.*-*" />
1313
<PackageReference Include="Microsoft.Extensions.AI" Version="9.5.0" />
1414
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.5.0-preview.1.25265.7" />
1515
</ItemGroup>

CS/Components/Pages/Index.razor

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
@using Microsoft.Extensions.AI
44
@using System.Text.RegularExpressions
55
@using System.Text
6+
@using Markdig
7+
@using Ganss.Xss
68
@rendermode InteractiveServer
79
<PageTitle>Welcome</PageTitle>
810
<DxDialogProvider />
@@ -40,7 +42,7 @@
4042
PositionTarget=".info-icon-btn"
4143
PreventCloseOnPositionTargetClick="true"
4244
Width="240">
43-
Specifies the randomness of response text. Higher values result in a more random output, while lower values make the output more focused and deterministic. Available values are from 0 to 2.
45+
Determines the randomness and creativity of responses. Low temperature makes the output predictable, factual, and consistent. High temperature makes the output more creative and diverse, but increases the chance of hallucinations. Range: 0–2.
4446
</DxFlyout>
4547
</div>
4648
</CaptionTemplate>
@@ -63,7 +65,7 @@
6365
PositionTarget=".info-icon-btn"
6466
PreventCloseOnPositionTargetClick="true"
6567
Width="240">
66-
Language models process text by dividing it into tokens, which can be words or groups of characters. Use the MaxOutputTokens property to limit the maximum number of tokens generated in a single output of a GPT model.
68+
Determines the maximum length of the model's response. Tokens represent words or pieces of words; approximately 750 words equal 1,000 tokens.
6769
</DxFlyout>
6870
</div>
6971
</CaptionTemplate>
@@ -74,7 +76,7 @@
7476

7577
<DxFormLayoutItem ColSpanMd="12">
7678
<Template>
77-
<DxButton Text="Send example prompt"
79+
<DxButton Text="Send sample message"
7880
Click="@SendSampleMessage"
7981
CssClass="width-full" />
8082
</Template>
@@ -111,9 +113,9 @@
111113

112114
<DxPopup @bind-Visible="@IsSystemPromptVisible"
113115
ShowFooter="true"
114-
HeaderText="Edit Contact">
116+
HeaderText="Instructions">
115117
<BodyContentTemplate>
116-
The system prompt is provided below. You may edit it, and any changes will take effect in the chat after you clear it.
118+
Modify the system prompt below. Changes apply after you clear the current chat session.
117119
<DxMemo @bind-Text="SystemPrompt" CssClass="height-300" />
118120
</BodyContentTemplate>
119121
</DxPopup>
@@ -124,6 +126,7 @@
124126
[Inject] IChatClient ChatClient { get; set; } = default!;
125127
[Inject] IDialogService DialogService { get; set; }
126128
DxAIChat RefAiChat;
129+
private readonly HtmlSanitizer sanitizer = new HtmlSanitizer();
127130
string SystemPrompt { get; set; }
128131
bool IsSystemPromptVisible { get; set; } = false;
129132
float? Temperature { get; set; } = 0;
@@ -147,6 +150,12 @@
147150
ChatRole.User);
148151
}
149152

153+
MarkupString ToHtml(string markdown) {
154+
string html = Markdown.ToHtml(markdown);
155+
html = sanitizer.Sanitize(html);
156+
return new MarkupString(html);
157+
}
158+
150159
void ResetChat() {
151160

152161
List<BlazorChatMessage> initialMessages = new(){

CS/README.md

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)