From 1a49aedd862562bcd1d39dc0c7a851ec1763583c Mon Sep 17 00:00:00 2001 From: Gil LaHaye Date: Mon, 13 Nov 2023 19:46:36 -0500 Subject: [PATCH] Update CC to SK 1.0.0 Beta 6 (#609) ### Motivation and Context A few breaking changes occurred in SK 1.0.0 beta 6 ### Description Update to SK 1.0.0 beta 6 and adapt code to support the breaking changes from the library ### Contribution Checklist - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone :smile: --- .../CopilotChatMemoryPipeline.csproj | 4 +-- shared/CopilotChatShared.csproj | 2 +- webapi/Controllers/ChatController.cs | 8 +++--- webapi/CopilotChatWebApi.csproj | 28 +++++++++---------- webapi/Services/SemanticKernelProvider.cs | 6 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/memorypipeline/CopilotChatMemoryPipeline.csproj b/memorypipeline/CopilotChatMemoryPipeline.csproj index fc2cf32dd..8f9e4ffa0 100644 --- a/memorypipeline/CopilotChatMemoryPipeline.csproj +++ b/memorypipeline/CopilotChatMemoryPipeline.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/shared/CopilotChatShared.csproj b/shared/CopilotChatShared.csproj index a675325d0..6a46f5134 100644 --- a/shared/CopilotChatShared.csproj +++ b/shared/CopilotChatShared.csproj @@ -9,7 +9,7 @@ - + diff --git a/webapi/Controllers/ChatController.cs b/webapi/Controllers/ChatController.cs index 59e313a36..a01c48e3e 100644 --- a/webapi/Controllers/ChatController.cs +++ b/webapi/Controllers/ChatController.cs @@ -279,7 +279,7 @@ private async Task RegisterPlannerFunctionsAsync(CopilotChatPlanner planner, Dic { this._logger.LogInformation("Enabling GitHub plugin."); BearerAuthenticationProvider authenticationProvider = new(() => Task.FromResult(GithubAuthHeader)); - await planner.Kernel.ImportPluginFunctionsAsync( + await planner.Kernel.ImportOpenApiPluginFunctionsAsync( pluginName: "GitHubPlugin", filePath: Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Plugins", "OpenApi/GitHubPlugin/openapi.json"), new OpenApiFunctionExecutionParameters @@ -295,7 +295,7 @@ await planner.Kernel.ImportPluginFunctionsAsync( var authenticationProvider = new BasicAuthenticationProvider(() => { return Task.FromResult(JiraAuthHeader); }); var hasServerUrlOverride = variables.TryGetValue("jira-server-url", out string? serverUrlOverride); - await planner.Kernel.ImportPluginFunctionsAsync( + await planner.Kernel.ImportOpenApiPluginFunctionsAsync( pluginName: "JiraPlugin", filePath: Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Plugins", "OpenApi/JiraPlugin/openapi.json"), new OpenApiFunctionExecutionParameters @@ -334,7 +334,7 @@ await planner.Kernel.ImportPluginFunctionsAsync( var requiresAuth = !plugin.AuthType.Equals("none", StringComparison.OrdinalIgnoreCase); BearerAuthenticationProvider authenticationProvider = new(() => Task.FromResult(PluginAuthValue)); - await planner.Kernel.ImportPluginFunctionsAsync( + await planner.Kernel.ImportOpenApiPluginFunctionsAsync( $"{plugin.NameForModel}Plugin", PluginUtils.GetPluginManifestUri(plugin.ManifestDomain), new OpenApiFunctionExecutionParameters @@ -386,7 +386,7 @@ private async Task RegisterPlannerHostedFunctionsUsedAsync(CopilotChatPlanner pl () => Task.FromResult(plugin.Key)); // Register the ChatGPT plugin with the planner's kernel. - await planner.Kernel.ImportPluginFunctionsAsync( + await planner.Kernel.ImportOpenApiPluginFunctionsAsync( PluginUtils.SanitizePluginName(plugin.Name), PluginUtils.GetPluginManifestUri(plugin.ManifestDomain), new OpenApiFunctionExecutionParameters diff --git a/webapi/CopilotChatWebApi.csproj b/webapi/CopilotChatWebApi.csproj index ef53e95ba..b2ad3f4b3 100644 --- a/webapi/CopilotChatWebApi.csproj +++ b/webapi/CopilotChatWebApi.csproj @@ -21,18 +21,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -57,7 +57,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -67,7 +67,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/webapi/Services/SemanticKernelProvider.cs b/webapi/Services/SemanticKernelProvider.cs index 8efccefa8..746227d2d 100644 --- a/webapi/Services/SemanticKernelProvider.cs +++ b/webapi/Services/SemanticKernelProvider.cs @@ -69,7 +69,7 @@ private static KernelBuilder InitializeCompletionKernel( case string y when y.Equals("AzureOpenAIText", StringComparison.OrdinalIgnoreCase): var azureAIOptions = memoryOptions.GetServiceConfig(configuration, "AzureOpenAIText"); #pragma warning disable CA2000 // No need to dispose of HttpClient instances from IHttpClientFactory - builder.WithAzureChatCompletionService( + builder.WithAzureOpenAIChatCompletionService( azureAIOptions.Deployment, azureAIOptions.Endpoint, azureAIOptions.APIKey, @@ -112,7 +112,7 @@ private static KernelBuilder InitializePlannerKernel( case string y when y.Equals("AzureOpenAIText", StringComparison.OrdinalIgnoreCase): var azureAIOptions = memoryOptions.GetServiceConfig(configuration, "AzureOpenAIText"); #pragma warning disable CA2000 // No need to dispose of HttpClient instances from IHttpClientFactory - builder.WithAzureChatCompletionService( + builder.WithAzureOpenAIChatCompletionService( plannerOptions.Model, azureAIOptions.Endpoint, azureAIOptions.APIKey, @@ -155,7 +155,7 @@ private static MemoryBuilder InitializeMigrationMemory( case string y when y.Equals("AzureOpenAIEmbedding", StringComparison.OrdinalIgnoreCase): var azureAIOptions = memoryOptions.GetServiceConfig(configuration, "AzureOpenAIEmbedding"); #pragma warning disable CA2000 // No need to dispose of HttpClient instances from IHttpClientFactory - builder.WithAzureTextEmbeddingGenerationService( + builder.WithAzureOpenAITextEmbeddingGenerationService( azureAIOptions.Deployment, azureAIOptions.Endpoint, azureAIOptions.APIKey,