|
3 | 3 | @using Microsoft.Extensions.AI |
4 | 4 | @using System.Text.RegularExpressions |
5 | 5 | @using System.Text |
| 6 | +@using Markdig |
| 7 | +@using Ganss.Xss |
6 | 8 | @rendermode InteractiveServer |
7 | 9 | <PageTitle>Welcome</PageTitle> |
8 | 10 | <DxDialogProvider /> |
|
40 | 42 | PositionTarget=".info-icon-btn" |
41 | 43 | PreventCloseOnPositionTargetClick="true" |
42 | 44 | 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. |
44 | 46 | </DxFlyout> |
45 | 47 | </div> |
46 | 48 | </CaptionTemplate> |
|
63 | 65 | PositionTarget=".info-icon-btn" |
64 | 66 | PreventCloseOnPositionTargetClick="true" |
65 | 67 | 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. |
67 | 69 | </DxFlyout> |
68 | 70 | </div> |
69 | 71 | </CaptionTemplate> |
|
74 | 76 |
|
75 | 77 | <DxFormLayoutItem ColSpanMd="12"> |
76 | 78 | <Template> |
77 | | - <DxButton Text="Send example prompt" |
| 79 | + <DxButton Text="Send sample message" |
78 | 80 | Click="@SendSampleMessage" |
79 | 81 | CssClass="width-full" /> |
80 | 82 | </Template> |
|
111 | 113 |
|
112 | 114 | <DxPopup @bind-Visible="@IsSystemPromptVisible" |
113 | 115 | ShowFooter="true" |
114 | | - HeaderText="Edit Contact"> |
| 116 | + HeaderText="Instructions"> |
115 | 117 | <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. |
117 | 119 | <DxMemo @bind-Text="SystemPrompt" CssClass="height-300" /> |
118 | 120 | </BodyContentTemplate> |
119 | 121 | </DxPopup> |
|
124 | 126 | [Inject] IChatClient ChatClient { get; set; } = default!; |
125 | 127 | [Inject] IDialogService DialogService { get; set; } |
126 | 128 | DxAIChat RefAiChat; |
| 129 | + private readonly HtmlSanitizer sanitizer = new HtmlSanitizer(); |
127 | 130 | string SystemPrompt { get; set; } |
128 | 131 | bool IsSystemPromptVisible { get; set; } = false; |
129 | 132 | float? Temperature { get; set; } = 0; |
|
147 | 150 | ChatRole.User); |
148 | 151 | } |
149 | 152 |
|
| 153 | + MarkupString ToHtml(string markdown) { |
| 154 | + string html = Markdown.ToHtml(markdown); |
| 155 | + html = sanitizer.Sanitize(html); |
| 156 | + return new MarkupString(html); |
| 157 | + } |
| 158 | + |
150 | 159 | void ResetChat() { |
151 | 160 |
|
152 | 161 | List<BlazorChatMessage> initialMessages = new(){ |
|
0 commit comments