From a0fdbfd7351fb3ba9c781e366362b9650006ef8a Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Tue, 4 Feb 2025 17:09:55 +0000 Subject: [PATCH] Chat template CR feedback (#5845) * Change system prompt to be const * Improve metadata on SearchAsync --- .../Components/Pages/Chat/Chat.razor | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat/Chat.razor b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat/Chat.razor index f2e8c8f58b4..ac05dfdd824 100644 --- a/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat/Chat.razor +++ b/src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Pages/Chat/Chat.razor @@ -18,7 +18,7 @@ @code { - private readonly string systemPrompt = @" + private const string SystemPrompt = @" You are an assistant who answers questions about information you retrieve. Do not answer questions about anything else. Use only simple markdown to format your responses. @@ -39,7 +39,7 @@ protected override void OnInitialized() { - messages.Add(new(ChatRole.System, systemPrompt)); + messages.Add(new(ChatRole.System, SystemPrompt)); chatOptions.Tools = [AIFunctionFactory.Create(SearchAsync)]; } @@ -93,14 +93,15 @@ { CancelAnyCurrentResponse(); messages.Clear(); - messages.Add(new(ChatRole.System, systemPrompt)); + messages.Add(new(ChatRole.System, SystemPrompt)); chatSuggestions?.Clear(); await chatInput!.FocusAsync(); } + [Description("Searches for information using a phrase or keyword")] private async Task> SearchAsync( [Description("The phrase to search for.")] string searchPhrase, - [Description("Whenever possible, specify the filename to search that file only. If you leave this blank, we will search all files.")] string? filenameFilter = null) + [Description("Whenever possible, specify the filename to search that file only. If not provided, the search includes all files.")] string? filenameFilter = null) { await InvokeAsync(StateHasChanged); var results = await Search.SearchAsync(searchPhrase, filenameFilter, maxResults: 5);