diff --git a/webapi/Controllers/ChatMemoryController.cs b/webapi/Controllers/ChatMemoryController.cs index cda7de4c7..adc57ae74 100644 --- a/webapi/Controllers/ChatMemoryController.cs +++ b/webapi/Controllers/ChatMemoryController.cs @@ -97,7 +97,7 @@ await memoryClient.SearchMemoryAsync( this._promptOptions.MemoryIndexName, "*", relevanceThreshold: 0, - resultCount: 1, + resultCount: -1, chatId, memoryContainerName); diff --git a/webapi/Plugins/Chat/SemanticChatMemoryExtractor.cs b/webapi/Plugins/Chat/SemanticChatMemoryExtractor.cs index 6c7f1d90f..8011d2568 100644 --- a/webapi/Plugins/Chat/SemanticChatMemoryExtractor.cs +++ b/webapi/Plugins/Chat/SemanticChatMemoryExtractor.cs @@ -1,7 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. using System; +using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Threading; using System.Threading.Tasks; using CopilotChat.WebApi.Extensions; @@ -11,6 +13,7 @@ using Microsoft.Extensions.Logging; using Microsoft.KernelMemory; using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.Connectors.OpenAI; namespace CopilotChat.WebApi.Plugins.Chat; @@ -78,7 +81,13 @@ async Task ExtractCognitiveMemoryAsync(string memoryType, st options.ResponseTokenLimit - TokenUtils.TokenCount(memoryPrompt); - var memoryExtractionArguments = new KernelArguments(kernelArguments); +#pragma warning disable SKEXP0010 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + var memoryExtractionArguments = new KernelArguments(kernelArguments, executionSettings: new Dictionary + { + { PromptExecutionSettings.DefaultServiceId, new OpenAIPromptExecutionSettings { ResponseFormat = "json_object" } } + }); +#pragma warning restore SKEXP0010 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. + memoryExtractionArguments["tokenLimit"] = remainingToken.ToString(new NumberFormatInfo()); memoryExtractionArguments["memoryName"] = memoryName; memoryExtractionArguments["format"] = options.MemoryFormat;