Skip to content

Commit a0fdbfd

Browse files
Chat template CR feedback (#5845)
* Change system prompt to be const * Improve metadata on SearchAsync
1 parent 221db90 commit a0fdbfd

File tree

1 file changed

+5
-4
lines changed
  • src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat

1 file changed

+5
-4
lines changed

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat/Chat.razor

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</div>
1919

2020
@code {
21-
private readonly string systemPrompt = @"
21+
private const string SystemPrompt = @"
2222
You are an assistant who answers questions about information you retrieve.
2323
Do not answer questions about anything else.
2424
Use only simple markdown to format your responses.
@@ -39,7 +39,7 @@
3939

4040
protected override void OnInitialized()
4141
{
42-
messages.Add(new(ChatRole.System, systemPrompt));
42+
messages.Add(new(ChatRole.System, SystemPrompt));
4343
chatOptions.Tools = [AIFunctionFactory.Create(SearchAsync)];
4444
}
4545

@@ -93,14 +93,15 @@
9393
{
9494
CancelAnyCurrentResponse();
9595
messages.Clear();
96-
messages.Add(new(ChatRole.System, systemPrompt));
96+
messages.Add(new(ChatRole.System, SystemPrompt));
9797
chatSuggestions?.Clear();
9898
await chatInput!.FocusAsync();
9999
}
100100

101+
[Description("Searches for information using a phrase or keyword")]
101102
private async Task<IEnumerable<string>> SearchAsync(
102103
[Description("The phrase to search for.")] string searchPhrase,
103-
[Description("Whenever possible, specify the filename to search that file only. If you leave this blank, we will search all files.")] string? filenameFilter = null)
104+
[Description("Whenever possible, specify the filename to search that file only. If not provided, the search includes all files.")] string? filenameFilter = null)
104105
{
105106
await InvokeAsync(StateHasChanged);
106107
var results = await Search.SearchAsync(searchPhrase, filenameFilter, maxResults: 5);

0 commit comments

Comments
 (0)