diff --git a/dotnet/SK-dotnet.sln b/dotnet/SK-dotnet.sln index d9ff45c711..50482f5f52 100644 --- a/dotnet/SK-dotnet.sln +++ b/dotnet/SK-dotnet.sln @@ -139,8 +139,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationInsightsExample" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connectors.Memory.Kusto", "src\Connectors\Connectors.Memory.Kusto\Connectors.Memory.Kusto.csproj", "{E07608CC-D710-4655-BB9E-D22CF3CDD193}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateEngine.Basic", "src\Extensions\TemplateEngine.Basic\TemplateEngine.Basic.csproj", "{10E4B697-D4E8-468D-872D-49670FD150FB}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reliability.Polly", "src\Extensions\Reliability.Polly\Reliability.Polly.csproj", "{D4540A0F-98E3-4E70-9093-1948AE5B2AAD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reliability.Basic", "src\Extensions\Reliability.Basic\Reliability.Basic.csproj", "{3DC4DBD8-20A5-4937-B4F5-BB5E24E7A567}" @@ -355,12 +353,6 @@ Global {E07608CC-D710-4655-BB9E-D22CF3CDD193}.Publish|Any CPU.Build.0 = Publish|Any CPU {E07608CC-D710-4655-BB9E-D22CF3CDD193}.Release|Any CPU.ActiveCfg = Release|Any CPU {E07608CC-D710-4655-BB9E-D22CF3CDD193}.Release|Any CPU.Build.0 = Release|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Publish|Any CPU.ActiveCfg = Publish|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Publish|Any CPU.Build.0 = Publish|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10E4B697-D4E8-468D-872D-49670FD150FB}.Release|Any CPU.Build.0 = Release|Any CPU {D4540A0F-98E3-4E70-9093-1948AE5B2AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D4540A0F-98E3-4E70-9093-1948AE5B2AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU {D4540A0F-98E3-4E70-9093-1948AE5B2AAD}.Publish|Any CPU.ActiveCfg = Publish|Any CPU @@ -497,7 +489,6 @@ Global {E6EDAB8F-3406-4DBF-9AAB-DF40DC2CA0FA} = {FA3720F1-C99A-49B2-9577-A940257098BF} {C754950A-E16C-4F96-9CC7-9328E361B5AF} = {FA3720F1-C99A-49B2-9577-A940257098BF} {E07608CC-D710-4655-BB9E-D22CF3CDD193} = {0247C2C9-86C3-45BA-8873-28B0948EDC0C} - {10E4B697-D4E8-468D-872D-49670FD150FB} = {078F96B4-09E1-4E0E-B214-F71A4F4BF633} {D4540A0F-98E3-4E70-9093-1948AE5B2AAD} = {078F96B4-09E1-4E0E-B214-F71A4F4BF633} {3DC4DBD8-20A5-4937-B4F5-BB5E24E7A567} = {078F96B4-09E1-4E0E-B214-F71A4F4BF633} {D6D598DF-C17C-46F4-B2B9-CDE82E2DE132} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0} diff --git a/dotnet/notebooks/03-semantic-function-inline.ipynb b/dotnet/notebooks/03-semantic-function-inline.ipynb index 70fe7ec7bd..87d3fad634 100644 --- a/dotnet/notebooks/03-semantic-function-inline.ipynb +++ b/dotnet/notebooks/03-semantic-function-inline.ipynb @@ -58,7 +58,6 @@ "using Microsoft.SemanticKernel;\n", "using Microsoft.SemanticKernel.Connectors.AI.OpenAI;\n", "using Microsoft.SemanticKernel.TemplateEngine;\n", - "using Microsoft.SemanticKernel.TemplateEngine.Basic;\n", "\n", "var builder = new KernelBuilder();\n", "\n", diff --git a/dotnet/notebooks/04-context-variables-chat.ipynb b/dotnet/notebooks/04-context-variables-chat.ipynb index 1e3e2b8075..521c4b2428 100644 --- a/dotnet/notebooks/04-context-variables-chat.ipynb +++ b/dotnet/notebooks/04-context-variables-chat.ipynb @@ -39,7 +39,6 @@ "\n", "using Microsoft.SemanticKernel;\n", "using Microsoft.SemanticKernel.TemplateEngine;\n", - "using Microsoft.SemanticKernel.TemplateEngine.Basic;\n", "using Microsoft.SemanticKernel.Orchestration;\n", "using Microsoft.SemanticKernel.Connectors.AI.OpenAI;\n", "\n", diff --git a/dotnet/samples/ApplicationInsightsExample/ApplicationInsightsExample.csproj b/dotnet/samples/ApplicationInsightsExample/ApplicationInsightsExample.csproj index 3957425441..aae365f38a 100644 --- a/dotnet/samples/ApplicationInsightsExample/ApplicationInsightsExample.csproj +++ b/dotnet/samples/ApplicationInsightsExample/ApplicationInsightsExample.csproj @@ -21,7 +21,6 @@ - diff --git a/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs b/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs index bd594d596d..37bf9147a5 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example06_TemplateLanguage.cs @@ -6,7 +6,6 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Connectors.AI.OpenAI; using Microsoft.SemanticKernel.Plugins.Core; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using RepoUtils; // ReSharper disable once InconsistentNaming @@ -52,7 +51,7 @@ Is it weekend time (weekend/not weekend)? // This allows to see the prompt before it's sent to OpenAI Console.WriteLine("--- Rendered Prompt"); - var promptTemplateFactory = new BasicPromptTemplateFactory(); + var promptTemplateFactory = new KernelPromptTemplateFactory(); var promptTemplate = promptTemplateFactory.Create(FunctionDefinition, new PromptTemplateConfig()); var renderedPrompt = await promptTemplate.RenderAsync(kernel.CreateNewContext()); Console.WriteLine(renderedPrompt); diff --git a/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs b/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs index 9a7a3290b4..c05b054e08 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example07_BingAndGooglePlugins.cs @@ -8,7 +8,6 @@ using Microsoft.SemanticKernel.Plugins.Web; using Microsoft.SemanticKernel.Plugins.Web.Bing; using Microsoft.SemanticKernel.Plugins.Web.Google; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using RepoUtils; /// @@ -150,7 +149,7 @@ Answer: "; // If the answer contains commands, execute them using the prompt renderer. if (result.Contains("bing.search", StringComparison.OrdinalIgnoreCase)) { - var promptTemplateFactory = new BasicPromptTemplateFactory(); + var promptTemplateFactory = new KernelPromptTemplateFactory(); var promptTemplate = promptTemplateFactory.Create(result, new PromptTemplateConfig()); Console.WriteLine("---- Fetching information from Bing..."); diff --git a/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs b/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs index fd2cad3859..baa287af4f 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example30_ChatWithPrompts.cs @@ -7,7 +7,6 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.AI.ChatCompletion; using Microsoft.SemanticKernel.Plugins.Core; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using RepoUtils; using Resources; @@ -41,7 +40,7 @@ using Resources; * var context = kernel.CreateNewContext(); * ... set variables ... * - * var promptRenderer = new BasicPromptTemplateEngine(); + * var promptRenderer = new KernelPromptTemplateEngine(); * string renderedPrompt = await promptRenderer.RenderAsync("...prompt template...", context); */ // ReSharper disable CommentTypo @@ -87,7 +86,7 @@ public static class Example30_ChatWithPrompts // Instantiate the prompt template factory, which we will use to turn prompt templates // into strings, that we will store into a Chat history object, which is then sent // to the Chat Model. - var promptTemplateFactory = new BasicPromptTemplateFactory(); + var promptTemplateFactory = new KernelPromptTemplateFactory(); // Render the system prompt. This string is used to configure the chat. // This contains the context, ie a piece of a wikipedia page selected by the user. diff --git a/dotnet/samples/KernelSyntaxExamples/Example56_TemplateNativeFunctionsWithMultipleArguments.cs b/dotnet/samples/KernelSyntaxExamples/Example56_TemplateNativeFunctionsWithMultipleArguments.cs index 0de886e67e..92277b7a10 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example56_TemplateNativeFunctionsWithMultipleArguments.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example56_TemplateNativeFunctionsWithMultipleArguments.cs @@ -6,7 +6,6 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Connectors.AI.OpenAI; using Microsoft.SemanticKernel.Plugins.Core; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using RepoUtils; // ReSharper disable once InconsistentNaming @@ -56,7 +55,7 @@ public static class Example56_TemplateNativeFunctionsWithMultipleArguments // This allows to see the prompt before it's sent to OpenAI Console.WriteLine("--- Rendered Prompt"); - var promptTemplateFactory = new BasicPromptTemplateFactory(); + var promptTemplateFactory = new KernelPromptTemplateFactory(); var promptTemplate = promptTemplateFactory.Create(FunctionDefinition, new PromptTemplateConfig()); var renderedPrompt = await promptTemplate.RenderAsync(context); Console.WriteLine(renderedPrompt); diff --git a/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs b/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs index b12a4ea620..79b5fbb8d6 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example64_MultiplePromptTemplates.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using Microsoft.SemanticKernel.TemplateEngine.Handlebars; using RepoUtils; @@ -42,7 +41,7 @@ public static class Example64_MultiplePromptTemplates .Build(); var promptTemplateFactory = new AggregatorPromptTemplateFactory( - new BasicPromptTemplateFactory(), + new KernelPromptTemplateFactory(), new HandlebarsPromptTemplateFactory()); var skPrompt = "Hello AI, my name is {{$name}}. What is the origin of my name?"; diff --git a/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj b/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj index f5e7dc3cdc..a25845aa27 100644 --- a/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj +++ b/dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj @@ -45,7 +45,6 @@ - diff --git a/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj b/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj index e244d8c081..8ac112cc1a 100644 --- a/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj +++ b/dotnet/src/Experimental/Orchestration.Flow.IntegrationTests/Experimental.Orchestration.Flow.IntegrationTests.csproj @@ -33,7 +33,6 @@ - diff --git a/dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs b/dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs index 2fa29c2277..fb320f5f1d 100644 --- a/dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs +++ b/dotnet/src/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs @@ -12,7 +12,6 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Experimental.Orchestration.Abstractions; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; namespace Microsoft.SemanticKernel.Experimental.Orchestration.Execution; @@ -684,7 +683,7 @@ internal class FlowExecutor : IFlowExecutor private ISKFunction ImportSemanticFunction(IKernel kernel, string functionName, string promptTemplate, PromptTemplateConfig config) { - var factory = new BasicPromptTemplateFactory(kernel.LoggerFactory); + var factory = new KernelPromptTemplateFactory(kernel.LoggerFactory); var template = factory.Create(promptTemplate, config); return kernel.RegisterSemanticFunction(RestrictedPluginName, functionName, config, template); diff --git a/dotnet/src/Experimental/Orchestration.Flow/Execution/ReActEngine.cs b/dotnet/src/Experimental/Orchestration.Flow/Execution/ReActEngine.cs index 4081efbbba..182cdd9cfb 100644 --- a/dotnet/src/Experimental/Orchestration.Flow/Execution/ReActEngine.cs +++ b/dotnet/src/Experimental/Orchestration.Flow/Execution/ReActEngine.cs @@ -10,7 +10,6 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.AI.ChatCompletion; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; namespace Microsoft.SemanticKernel.Experimental.Orchestration.Execution; @@ -235,7 +234,7 @@ internal sealed class ReActEngine private ISKFunction ImportSemanticFunction(IKernel kernel, string functionName, string promptTemplate, PromptTemplateConfig config) { - var factory = new BasicPromptTemplateFactory(kernel.LoggerFactory); + var factory = new KernelPromptTemplateFactory(kernel.LoggerFactory); var template = factory.Create(promptTemplate, config); return kernel.RegisterSemanticFunction(RestrictedPluginName, functionName, config, template); diff --git a/dotnet/src/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj b/dotnet/src/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj index e77d18b73b..6ab88b788f 100644 --- a/dotnet/src/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj +++ b/dotnet/src/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj @@ -26,7 +26,6 @@ - diff --git a/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj b/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj index e529bd15da..356fa7ff5b 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj +++ b/dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj @@ -26,7 +26,6 @@ - diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Extensions/KernelBasicPromptTemplateExtensions.cs b/dotnet/src/Extensions/TemplateEngine.Basic/Extensions/KernelBasicPromptTemplateExtensions.cs deleted file mode 100644 index 57cf40cc5b..0000000000 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Extensions/KernelBasicPromptTemplateExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; - -#pragma warning disable IDE0130 -// ReSharper disable once CheckNamespace - Using the namespace of IKernel -namespace Microsoft.SemanticKernel; -#pragma warning restore IDE0130 - -/// -/// Class for extensions methods to define semantic functions using the basic prompt template factory. -/// -public static class KernelBasicPromptTemplateExtensions -{ - /// - /// Build and register a function in the internal function collection, in a global generic plugin. - /// - /// Semantic Kernel instance - /// Name of the semantic function. The name can contain only alphanumeric chars + underscore. - /// Prompt template string. - /// Prompt template configuration. - /// A C# function wrapping AI logic, usually defined with natural language - public static ISKFunction RegisterSemanticFunction( - this IKernel kernel, - string functionName, - string templateString, - PromptTemplateConfig promptTemplateConfig) - { - var promptTemplateFactory = new BasicPromptTemplateFactory(loggerFactory: kernel.LoggerFactory); - var promptTemplate = promptTemplateFactory.Create(templateString, promptTemplateConfig); - return kernel.RegisterSemanticFunction(functionName, promptTemplateConfig, promptTemplate); - } - - /// - /// Build and register a function in the internal function collection, in a global generic plugin. - /// - /// Semantic Kernel instance - /// - /// Name of the semantic function. The name can contain only alphanumeric chars + underscore. - /// Prompt template string. - /// Prompt template configuration. - /// A C# function wrapping AI logic, usually defined with natural language - public static ISKFunction RegisterSemanticFunction( - this IKernel kernel, - string pluginName, - string functionName, - string templateString, - PromptTemplateConfig promptTemplateConfig) - { - var promptTemplateFactory = new BasicPromptTemplateFactory(loggerFactory: kernel.LoggerFactory); - var promptTemplate = promptTemplateFactory.Create(templateString, promptTemplateConfig); - return kernel.RegisterSemanticFunction(pluginName, functionName, promptTemplateConfig, promptTemplate); - } -} diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/TemplateEngine.Basic.csproj b/dotnet/src/Extensions/TemplateEngine.Basic/TemplateEngine.Basic.csproj deleted file mode 100644 index f07f24a23f..0000000000 --- a/dotnet/src/Extensions/TemplateEngine.Basic/TemplateEngine.Basic.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Microsoft.SemanticKernel.TemplateEngine.Basic - Microsoft.SemanticKernel.TemplateEngine.Basic - netstandard2.0 - - - - - - - Semantic Kernel - Basic Prompt Template Engine - Semantic Kernel Basic Prompt Template Engine - - - - - - - - - - \ No newline at end of file diff --git a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs index 6065cef115..6fc35cb1b2 100644 --- a/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs +++ b/dotnet/src/IntegrationTests/Connectors/OpenAI/OpenAICompletionTests.cs @@ -12,7 +12,6 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Reliability.Basic; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using SemanticKernel.IntegrationTests.TestSettings; using Xunit; using Xunit.Abstractions; @@ -340,7 +339,7 @@ public sealed class OpenAICompletionTests : IDisposable { // Arrange var builder = this._kernelBuilder.WithLoggerFactory(this._logger); - var promptTemplateFactory = new BasicPromptTemplateFactory(); + var promptTemplateFactory = new KernelPromptTemplateFactory(); this.ConfigureAzureOpenAI(builder); this.ConfigureInvalidAzureOpenAI(builder); diff --git a/dotnet/src/IntegrationTests/IntegrationTests.csproj b/dotnet/src/IntegrationTests/IntegrationTests.csproj index 0cbcc2020d..d34f130e8e 100644 --- a/dotnet/src/IntegrationTests/IntegrationTests.csproj +++ b/dotnet/src/IntegrationTests/IntegrationTests.csproj @@ -39,7 +39,6 @@ - diff --git a/dotnet/src/IntegrationTests/TemplateLanguage/PromptTemplateEngineTests.cs b/dotnet/src/IntegrationTests/TemplateLanguage/PromptTemplateEngineTests.cs index 0ee6981e4f..8b645c6ad7 100644 --- a/dotnet/src/IntegrationTests/TemplateLanguage/PromptTemplateEngineTests.cs +++ b/dotnet/src/IntegrationTests/TemplateLanguage/PromptTemplateEngineTests.cs @@ -7,7 +7,7 @@ using System.IO; using System.Threading.Tasks; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Diagnostics; -using Microsoft.SemanticKernel.TemplateEngine.Basic; +using Microsoft.SemanticKernel.TemplateEngine; using Xunit; using Xunit.Abstractions; @@ -23,7 +23,7 @@ public sealed class PromptTemplateEngineTests : IDisposable public PromptTemplateEngineTests(ITestOutputHelper output) { this._logger = new RedirectOutput(output); - this._target = new BasicPromptTemplateEngine(); + this._target = new KernelPromptTemplateEngine(); } [Fact] @@ -208,7 +208,7 @@ public sealed class PromptTemplateEngineTests : IDisposable #region internals private readonly RedirectOutput _logger; - private readonly BasicPromptTemplateEngine _target; + private readonly KernelPromptTemplateEngine _target; private static IEnumerable GetTestData(string file) { diff --git a/dotnet/src/Planners/Planners.Core/Planners.Core.csproj b/dotnet/src/Planners/Planners.Core/Planners.Core.csproj index ec0cab6c17..2171d12822 100644 --- a/dotnet/src/Planners/Planners.Core/Planners.Core.csproj +++ b/dotnet/src/Planners/Planners.Core/Planners.Core.csproj @@ -63,7 +63,6 @@ - diff --git a/dotnet/src/Planners/Planners.Core/Stepwise/StepwisePlanner.cs b/dotnet/src/Planners/Planners.Core/Stepwise/StepwisePlanner.cs index 5ed728ef60..98653fd6e7 100644 --- a/dotnet/src/Planners/Planners.Core/Stepwise/StepwisePlanner.cs +++ b/dotnet/src/Planners/Planners.Core/Stepwise/StepwisePlanner.cs @@ -18,7 +18,6 @@ using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Planning; using Microsoft.SemanticKernel.Services; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; #pragma warning disable IDE0130 // ReSharper disable once CheckNamespace - Using NS of Plan @@ -61,7 +60,7 @@ public class StepwisePlanner : IStepwisePlanner this._promptConfig.SetMaxTokens(this.Config.MaxCompletionTokens); // Initialize prompt renderer - this._promptTemplateFactory = new BasicPromptTemplateFactory(this._kernel.LoggerFactory); + this._promptTemplateFactory = new KernelPromptTemplateFactory(this._kernel.LoggerFactory); // Import native functions this._nativeFunctions = this._kernel.ImportFunctions(this, RestrictedPluginName); @@ -651,7 +650,7 @@ public class StepwisePlanner : IStepwisePlanner /// /// The prompt renderer to use for the system step /// - private readonly BasicPromptTemplateFactory _promptTemplateFactory; + private readonly KernelPromptTemplateFactory _promptTemplateFactory; /// /// The prompt config to use for the system step diff --git a/dotnet/src/Planners/Planners.OpenAI/Planners.OpenAI.csproj b/dotnet/src/Planners/Planners.OpenAI/Planners.OpenAI.csproj index 4bc92ae8b0..917661755d 100644 --- a/dotnet/src/Planners/Planners.OpenAI/Planners.OpenAI.csproj +++ b/dotnet/src/Planners/Planners.OpenAI/Planners.OpenAI.csproj @@ -30,7 +30,6 @@ - diff --git a/dotnet/src/Planners/Planners.OpenAI/Stepwise/FunctionCallingStepwisePlanner.cs b/dotnet/src/Planners/Planners.OpenAI/Stepwise/FunctionCallingStepwisePlanner.cs index 0eb1c0f140..5243518a42 100644 --- a/dotnet/src/Planners/Planners.OpenAI/Stepwise/FunctionCallingStepwisePlanner.cs +++ b/dotnet/src/Planners/Planners.OpenAI/Stepwise/FunctionCallingStepwisePlanner.cs @@ -15,7 +15,6 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Functions.OpenAPI.Model; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; #pragma warning disable IDE0130 // ReSharper disable once CheckNamespace - Using NS of Plan @@ -41,7 +40,7 @@ public sealed class FunctionCallingStepwisePlanner this._chatCompletion = kernel.GetService(); // Initialize prompt renderer - this._promptTemplateFactory = new BasicPromptTemplateFactory(this._kernel.LoggerFactory); + this._promptTemplateFactory = new KernelPromptTemplateFactory(this._kernel.LoggerFactory); // Set up Config with default values and excluded plugins this.Config = config ?? new(); @@ -297,7 +296,7 @@ public sealed class FunctionCallingStepwisePlanner /// /// The prompt renderer to use for the system step /// - private readonly BasicPromptTemplateFactory _promptTemplateFactory; + private readonly KernelPromptTemplateFactory _promptTemplateFactory; /// /// The name to use when creating semantic functions that are restricted from plan creation diff --git a/dotnet/src/SemanticKernel.Core/Extensions/KernelSemanticFunctionExtensions.cs b/dotnet/src/SemanticKernel.Core/Extensions/KernelSemanticFunctionExtensions.cs index b3754bd594..d809c9346a 100644 --- a/dotnet/src/SemanticKernel.Core/Extensions/KernelSemanticFunctionExtensions.cs +++ b/dotnet/src/SemanticKernel.Core/Extensions/KernelSemanticFunctionExtensions.cs @@ -4,9 +4,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.AI; @@ -25,6 +22,25 @@ namespace Microsoft.SemanticKernel; /// public static class KernelSemanticFunctionExtensions { + /// + /// Build and register a function in the internal function collection, in a global generic plugin. + /// + /// Semantic Kernel instance + /// Name of the semantic function. The name can contain only alphanumeric chars + underscore. + /// Prompt template string. + /// Prompt template configuration. + /// A C# function wrapping AI logic, usually defined with natural language + public static ISKFunction RegisterSemanticFunction( + this IKernel kernel, + string functionName, + string templateString, + PromptTemplateConfig promptTemplateConfig) + { + var promptTemplateFactory = new KernelPromptTemplateFactory(loggerFactory: kernel.LoggerFactory); + var promptTemplate = promptTemplateFactory.Create(templateString, promptTemplateConfig); + return kernel.RegisterSemanticFunction(functionName, promptTemplateConfig, promptTemplate); + } + /// /// Build and register a function in the internal function collection, in a global generic plugin. /// @@ -127,7 +143,7 @@ public static class KernelSemanticFunctionExtensions Verify.ValidFunctionName(functionName); if (!string.IsNullOrEmpty(pluginName)) { Verify.ValidPluginName(pluginName); } - var factory = promptTemplateFactory ?? CreateDefaultPromptTemplateFactory(kernel); + var factory = promptTemplateFactory ?? new KernelPromptTemplateFactory(kernel.LoggerFactory); IPromptTemplate promptTemplateInstance = factory.Create(promptTemplate, promptTemplateConfig); // TODO: manage overwrites, potentially error out @@ -247,7 +263,7 @@ public static class KernelSemanticFunctionExtensions const string ConfigFile = "config.json"; const string PromptFile = "skprompt.txt"; - var factory = promptTemplateFactory ?? CreateDefaultPromptTemplateFactory(kernel); + var factory = promptTemplateFactory ?? new KernelPromptTemplateFactory(kernel.LoggerFactory); var functions = new Dictionary(); ILogger? logger = null; @@ -312,99 +328,6 @@ public static class KernelSemanticFunctionExtensions kernel.LoggerFactory ); } - - private const string BasicTemplateFactoryAssemblyName = "Microsoft.SemanticKernel.TemplateEngine.Basic"; - private const string BasicTemplateFactoryTypeName = "BasicPromptTemplateFactory"; - private static bool s_promptTemplateFactoryInitialized = false; - private static Type? s_promptTemplateFactoryType = null; - - /// - /// Create a default prompt template factory. - /// - /// This is a temporary solution to avoid breaking existing clients. - /// There will be a separate task to add support for registering instances of IPromptTemplateEngine and obsoleting the current approach. - /// - /// - /// Kernel instance - /// Instance of . - private static IPromptTemplateFactory CreateDefaultPromptTemplateFactory(IKernel kernel) - { -#pragma warning disable CS0618 // Type or member is obsolete - if (kernel.PromptTemplateEngine is not null) - { - return new PromptTemplateFactory(kernel.PromptTemplateEngine); - } -#pragma warning restore CS0618 // Type or member is obsolete - - if (!s_promptTemplateFactoryInitialized) - { - s_promptTemplateFactoryType = GetPromptTemplateFactoryType(); - s_promptTemplateFactoryInitialized = true; - } - - if (s_promptTemplateFactoryType is not null) - { - var constructor = s_promptTemplateFactoryType.GetConstructor(new Type[] { typeof(ILoggerFactory) }); - if (constructor is not null) - { -#pragma warning disable CS8601 // Null logger factory is OK - var factory = (IPromptTemplateFactory)constructor.Invoke(new object[] { kernel.LoggerFactory }); - if (factory is not null) - { - return factory; - } -#pragma warning restore CS8601 - } - } - - return new NullPromptTemplateFactory(); - } - - /// - /// Get the prompt template engine type if available - /// - /// The type for the prompt template engine if available - private static Type? GetPromptTemplateFactoryType() - { - try - { - var assembly = Assembly.Load(BasicTemplateFactoryAssemblyName); - - return assembly.ExportedTypes.Single(type => - type.Name.Equals(BasicTemplateFactoryTypeName, StringComparison.Ordinal) && - type.GetInterface(nameof(IPromptTemplateFactory)) is not null); - } - catch (Exception ex) when (!ex.IsCriticalException()) - { - return null; - } - } - - private sealed class NullPromptTemplateFactory : IPromptTemplateFactory - { - public IPromptTemplate Create(string templateString, PromptTemplateConfig promptTemplateConfig) - { - return new NullPromptTemplate(templateString); - } - } - - private sealed class NullPromptTemplate : IPromptTemplate - { - private readonly string _templateText; - - public NullPromptTemplate(string templateText) - { - this._templateText = templateText; - } - - public IReadOnlyList Parameters => Array.Empty(); - - public Task RenderAsync(SKContext executionContext, CancellationToken cancellationToken = default) - { - return Task.FromResult(this._templateText); - } - } - #endregion #region Obsolete diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Block.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Block.cs similarity index 95% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Block.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Block.cs index 3e52052819..1ae75500bc 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Block.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Block.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; /// /// Base class for blocks parsed from a prompt template diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/BlockTypes.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/BlockTypes.cs similarity index 75% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/BlockTypes.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/BlockTypes.cs index 74e5833a4a..d69c8c8cdb 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/BlockTypes.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/BlockTypes.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal enum BlockTypes { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/CodeBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/CodeBlock.cs similarity index 99% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/CodeBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/CodeBlock.cs index 280d34b1d2..e2199a3179 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/CodeBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/CodeBlock.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; #pragma warning disable CA2254 // error strings are used also internally, not just for logging #pragma warning disable CA1031 // IsCriticalException is an internal utility and should not be used by extensions diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/FunctionIdBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/FunctionIdBlock.cs similarity index 97% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/FunctionIdBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/FunctionIdBlock.cs index 216da326c6..a058ffdd8c 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/FunctionIdBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/FunctionIdBlock.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal sealed class FunctionIdBlock : Block, ITextRendering { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ICodeRendering.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ICodeRendering.cs similarity index 92% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ICodeRendering.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ICodeRendering.cs index cbdf9ef9c5..93ec182b80 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ICodeRendering.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ICodeRendering.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; /// /// Interface of dynamic blocks that need async IO to be rendered. diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ITextRendering.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ITextRendering.cs similarity index 88% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ITextRendering.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ITextRendering.cs index 1fa75694c0..8f67259caa 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ITextRendering.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ITextRendering.cs @@ -2,7 +2,7 @@ using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; /// /// Interface of static blocks that don't need async IO to be rendered. diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/NamedArgBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/NamedArgBlock.cs similarity index 99% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/NamedArgBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/NamedArgBlock.cs index 0847c8df48..9d7da92882 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/NamedArgBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/NamedArgBlock.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; /// /// A that represents a named argument for a function call. diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Symbols.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Symbols.cs similarity index 89% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Symbols.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Symbols.cs index c0beefb7ba..e1b8e754e7 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/Symbols.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/Symbols.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal static class Symbols { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/TextBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/TextBlock.cs similarity index 92% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/TextBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/TextBlock.cs index 99d7c2e517..478bcba795 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/TextBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/TextBlock.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal sealed class TextBlock : Block, ITextRendering { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ValBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ValBlock.cs similarity index 97% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ValBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ValBlock.cs index 1ae186faa6..b5d4d41c21 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/ValBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/ValBlock.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal sealed class ValBlock : Block, ITextRendering { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/VarBlock.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/VarBlock.cs similarity index 97% rename from dotnet/src/Extensions/TemplateEngine.Basic/Blocks/VarBlock.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/VarBlock.cs index d348d63f62..95b39bf80b 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/Blocks/VarBlock.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/Blocks/VarBlock.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +namespace Microsoft.SemanticKernel.TemplateEngine.Blocks; internal sealed class VarBlock : Block, ITextRendering { diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/CodeTokenizer.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/CodeTokenizer.cs similarity index 99% rename from dotnet/src/Extensions/TemplateEngine.Basic/CodeTokenizer.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/CodeTokenizer.cs index 954fd00832..7efc259c37 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/CodeTokenizer.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/CodeTokenizer.cs @@ -6,9 +6,9 @@ using System.Text; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic; +namespace Microsoft.SemanticKernel.TemplateEngine; /// /// Simple tokenizer used for default SK template code language. diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplate.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplate.cs similarity index 94% rename from dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplate.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplate.cs index be24ecdc05..abbafe8dfd 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplate.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplate.cs @@ -10,9 +10,9 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic; +namespace Microsoft.SemanticKernel.TemplateEngine; /// /// Given a prompt, that might contain references to variables and functions: @@ -24,7 +24,7 @@ namespace Microsoft.SemanticKernel.TemplateEngine.Basic; /// - Functions do not receive the context variables, unless specified using a special variable /// - Functions can be invoked in order and in parallel so the context variables must be immutable when invoked within the template /// -public sealed class BasicPromptTemplate : IPromptTemplate +public sealed class KernelPromptTemplate : IPromptTemplate { /// /// Constructor for PromptTemplate. @@ -32,10 +32,10 @@ public sealed class BasicPromptTemplate : IPromptTemplate /// Prompt template string. /// Prompt template configuration /// Logger factory - public BasicPromptTemplate(string templateString, PromptTemplateConfig promptTemplateConfig, ILoggerFactory? loggerFactory = null) + public KernelPromptTemplate(string templateString, PromptTemplateConfig promptTemplateConfig, ILoggerFactory? loggerFactory = null) { this._loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; - this._logger = this._loggerFactory.CreateLogger(typeof(BasicPromptTemplate)); + this._logger = this._loggerFactory.CreateLogger(typeof(KernelPromptTemplate)); this._templateString = templateString; this._promptTemplateConfig = promptTemplateConfig; this._parameters = new(() => this.InitParameters()); diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateEngine.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateEngine.cs similarity index 91% rename from dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateEngine.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateEngine.cs index 1ef60d17c7..6fa5973f95 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateEngine.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateEngine.cs @@ -11,9 +11,9 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic; +namespace Microsoft.SemanticKernel.TemplateEngine; /// /// Given a prompt, that might contain references to variables and functions: @@ -25,22 +25,22 @@ namespace Microsoft.SemanticKernel.TemplateEngine.Basic; /// - Functions do not receive the context variables, unless specified using a special variable /// - Functions can be invoked in order and in parallel so the context variables must be immutable when invoked within the template /// -[Obsolete("Use BasicPromptTemplateFactory instead. This will be removed in a future release.")] +[Obsolete("Use KernelPromptTemplateFactory instead. This will be removed in a future release.")] [EditorBrowsable(EditorBrowsableState.Never)] -public class BasicPromptTemplateEngine : IPromptTemplateEngine +public class KernelPromptTemplateEngine : IPromptTemplateEngine { private readonly ILoggerFactory _loggerFactory; private readonly ILogger _logger; private readonly TemplateTokenizer _tokenizer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The to use for logging. If null, no logging will be performed. - public BasicPromptTemplateEngine(ILoggerFactory? loggerFactory = null) + public KernelPromptTemplateEngine(ILoggerFactory? loggerFactory = null) { this._loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; - this._logger = this._loggerFactory.CreateLogger(typeof(BasicPromptTemplateEngine)); + this._logger = this._loggerFactory.CreateLogger(typeof(KernelPromptTemplateEngine)); this._tokenizer = new TemplateTokenizer(this._loggerFactory); } diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateFactory.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateFactory.cs similarity index 72% rename from dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateFactory.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateFactory.cs index fde8b92b62..4d8042ed4b 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/BasicPromptTemplateFactory.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/KernelPromptTemplateFactory.cs @@ -4,20 +4,20 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic; +namespace Microsoft.SemanticKernel.TemplateEngine; /// /// Default implementation of for the semantic-kernel prompt template format. /// -public sealed class BasicPromptTemplateFactory : IPromptTemplateFactory +public sealed class KernelPromptTemplateFactory : IPromptTemplateFactory { private readonly ILoggerFactory _loggerFactory; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The to use for logging. If null, no logging will be performed. - public BasicPromptTemplateFactory(ILoggerFactory? loggerFactory = null) + public KernelPromptTemplateFactory(ILoggerFactory? loggerFactory = null) { this._loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; } @@ -27,7 +27,7 @@ public sealed class BasicPromptTemplateFactory : IPromptTemplateFactory { if (promptTemplateConfig.TemplateFormat.Equals(PromptTemplateConfig.SemanticKernelTemplateFormat, System.StringComparison.Ordinal)) { - return new BasicPromptTemplate(templateString, promptTemplateConfig, this._loggerFactory); + return new KernelPromptTemplate(templateString, promptTemplateConfig, this._loggerFactory); } throw new SKException($"Prompt template format {promptTemplateConfig.TemplateFormat} is not supported."); diff --git a/dotnet/src/Extensions/TemplateEngine.Basic/TemplateTokenizer.cs b/dotnet/src/SemanticKernel.Core/TemplateEngine/TemplateTokenizer.cs similarity index 98% rename from dotnet/src/Extensions/TemplateEngine.Basic/TemplateTokenizer.cs rename to dotnet/src/SemanticKernel.Core/TemplateEngine/TemplateTokenizer.cs index 10d00b1e2f..98aec59975 100644 --- a/dotnet/src/Extensions/TemplateEngine.Basic/TemplateTokenizer.cs +++ b/dotnet/src/SemanticKernel.Core/TemplateEngine/TemplateTokenizer.cs @@ -4,9 +4,9 @@ using System.Collections.Generic; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; -namespace Microsoft.SemanticKernel.TemplateEngine.Basic; +namespace Microsoft.SemanticKernel.TemplateEngine; /// /// Simple tokenizer used for default SK template language. diff --git a/dotnet/src/SemanticKernel.MetaPackage/SemanticKernel.MetaPackage.csproj b/dotnet/src/SemanticKernel.MetaPackage/SemanticKernel.MetaPackage.csproj index 3bd7bdee93..9a24fe7ec3 100644 --- a/dotnet/src/SemanticKernel.MetaPackage/SemanticKernel.MetaPackage.csproj +++ b/dotnet/src/SemanticKernel.MetaPackage/SemanticKernel.MetaPackage.csproj @@ -13,7 +13,6 @@ Empowers app owners to integrate cutting-edge LLM technology quickly and easily - diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/CodeBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/CodeBlockTests.cs similarity index 99% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/CodeBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/CodeBlockTests.cs index c45d478e77..deae925875 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/CodeBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/CodeBlockTests.cs @@ -11,7 +11,7 @@ using Microsoft.SemanticKernel.AI; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Services; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Moq; using Xunit; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/FunctionIdBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/FunctionIdBlockTests.cs similarity index 97% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/FunctionIdBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/FunctionIdBlockTests.cs index b5b7e884da..1372c815bb 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/FunctionIdBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/FunctionIdBlockTests.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt.Blocks; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/NamedArgBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/NamedArgBlockTests.cs similarity index 99% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/NamedArgBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/NamedArgBlockTests.cs index 507f0af0c1..5e10ce182f 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/NamedArgBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/NamedArgBlockTests.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt.Blocks; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/TextBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/TextBlockTests.cs similarity index 96% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/TextBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/TextBlockTests.cs index 278efa5e10..adf7d00380 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/TextBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/TextBlockTests.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt.Blocks; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/ValBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/ValBlockTests.cs similarity index 96% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/ValBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/ValBlockTests.cs index 90e5c10d9d..c070ea4fd8 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/ValBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/ValBlockTests.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt.Blocks; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/VarBlockTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/VarBlockTests.cs similarity index 98% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/VarBlockTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/VarBlockTests.cs index 2e7e2d53ed..85d1a92148 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/Blocks/VarBlockTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/Blocks/VarBlockTests.cs @@ -2,7 +2,7 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt.Blocks; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/CodeTokenizerTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/CodeTokenizerTests.cs similarity index 98% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/CodeTokenizerTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/CodeTokenizerTests.cs index 34afa3d0e3..921b6224d5 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/CodeTokenizerTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/CodeTokenizerTests.cs @@ -2,8 +2,8 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; -using Microsoft.SemanticKernel.TemplateEngine.Basic; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt; diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateFactoryTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateFactoryTests.cs similarity index 71% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateFactoryTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateFactoryTests.cs index 318ab73605..6ad4e7e14d 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateFactoryTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateFactoryTests.cs @@ -2,26 +2,25 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; using Xunit; -namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt; +namespace SemanticKernel.UnitTests.TemplateEngine; -public sealed class BasicPromptTemplateFactoryTests +public sealed class KernelPromptTemplateFactoryTests { [Fact] public void ItCreatesBasicPromptTemplateByDefault() { // Arrange var templateString = "{{$input}}"; - var target = new BasicPromptTemplateFactory(); + var target = new KernelPromptTemplateFactory(); // Act var result = target.Create(templateString, new PromptTemplateConfig()); // Assert Assert.NotNull(result); - Assert.True(result is BasicPromptTemplate); + Assert.True(result is KernelPromptTemplate); } [Fact] @@ -29,14 +28,14 @@ public sealed class BasicPromptTemplateFactoryTests { // Arrange var templateString = "{{$input}}"; - var target = new BasicPromptTemplateFactory(); + var target = new KernelPromptTemplateFactory(); // Act var result = target.Create(templateString, new PromptTemplateConfig() { TemplateFormat = "semantic-kernel" }); // Assert Assert.NotNull(result); - Assert.True(result is BasicPromptTemplate); + Assert.True(result is KernelPromptTemplate); } [Fact] @@ -44,7 +43,7 @@ public sealed class BasicPromptTemplateFactoryTests { // Arrange var templateString = "{{$input}}"; - var target = new BasicPromptTemplateFactory(); + var target = new KernelPromptTemplateFactory(); // Act // Assert diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateTests.cs similarity index 90% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateTests.cs index 3dc4928b7d..d82a001d98 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/BasicPromptTemplateTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/KernelPromptTemplateTests.cs @@ -13,19 +13,18 @@ using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Services; using Microsoft.SemanticKernel.TemplateEngine; -using Microsoft.SemanticKernel.TemplateEngine.Basic; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Moq; -using SemanticKernel.Extensions.UnitTests.XunitHelpers; +using SemanticKernel.UnitTests.XunitHelpers; using Xunit; using Xunit.Abstractions; -namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt; +namespace SemanticKernel.UnitTests.TemplateEngine; -public sealed class BasicPromptTemplateTests +public sealed class KernelPromptTemplateTests { private const string DateFormat = "M/d/yyyy"; - private readonly BasicPromptTemplateFactory _factory; + private readonly KernelPromptTemplateFactory _factory; private readonly ContextVariables _variables; private readonly Mock _functions; private readonly ITestOutputHelper _logger; @@ -34,10 +33,10 @@ public sealed class BasicPromptTemplateTests private readonly Mock _serviceProvider; private readonly Mock _serviceSelector; - public BasicPromptTemplateTests(ITestOutputHelper testOutputHelper) + public KernelPromptTemplateTests(ITestOutputHelper testOutputHelper) { this._logger = testOutputHelper; - this._factory = new BasicPromptTemplateFactory(TestConsoleLogger.LoggerFactory); + this._factory = new KernelPromptTemplateFactory(TestConsoleLogger.LoggerFactory); this._variables = new ContextVariables(Guid.NewGuid().ToString("X")); this._functions = new Mock(); this._kernel = new Mock(); @@ -52,7 +51,7 @@ public sealed class BasicPromptTemplateTests // Arrange var template = "{$x11} This {$a} is {$_a} a {{$x11}} test {{$x11}} " + "template {{foo}}{{bar $a}}{{baz $_a}}{{yay $x11}}{{food a='b' c = $d}}"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); // Act var blocks = target.ExtractBlocks(template); @@ -167,7 +166,7 @@ public sealed class BasicPromptTemplateTests this._variables.Update("INPUT-BAR"); var template = "foo-{{function}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); this.MockFunctionRunner(functions[0]); @@ -196,7 +195,7 @@ public sealed class BasicPromptTemplateTests this._variables.Set("myVar", "BAR"); var template = "foo-{{function $myVar}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); this.MockFunctionRunner(func); var context = this.MockContext(); @@ -218,7 +217,7 @@ public sealed class BasicPromptTemplateTests [Description("Slogan"), SKName("slogan")] string slogan, [Description("Date"), SKName("date")] DateTime date) { - var dateStr = date.ToString(BasicPromptTemplateTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } @@ -230,7 +229,7 @@ public sealed class BasicPromptTemplateTests this._variables.Set("input", "Mario"); this._variables.Set("someDate", "2023-08-25T00:00:00"); var template = "foo-{{function input=$input age='42' slogan='Let\\'s-a go!' date=$someDate}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); this.MockFunctionRunner(func); var context = this.MockContext(); @@ -252,7 +251,7 @@ public sealed class BasicPromptTemplateTests [Description("Slogan"), SKName("slogan")] string slogan, [Description("Date"), SKName("date")] DateTime date) { - var dateStr = date.ToString(BasicPromptTemplateTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } @@ -263,7 +262,7 @@ public sealed class BasicPromptTemplateTests this._variables.Set("input", "Mario"); this._variables.Set("someDate", "2023-08-25T00:00:00"); var template = "foo-{{function input=$input age=42 slogan='Let\\'s-a go!' date=$someDate}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); var context = this.MockContext(); // Act @@ -282,7 +281,7 @@ public sealed class BasicPromptTemplateTests [Description("Date"), SKName("date")] DateTime date) { this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); - var dateStr = date.ToString(BasicPromptTemplateTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } @@ -294,7 +293,7 @@ public sealed class BasicPromptTemplateTests this._variables.Set("someDate", "2023-08-25T00:00:00"); var template = "foo-{{function $input age='42' slogan='Let\\'s-a go!' date=$someDate}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); this.MockFunctionRunner(func); @@ -312,7 +311,7 @@ public sealed class BasicPromptTemplateTests { // Arrange var template = "{{func1}} {{func2}} {{func3 $myVar}}"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); this._variables.Update("BAR"); this._variables.Set("myVar", "BAZ"); @@ -369,7 +368,7 @@ public sealed class BasicPromptTemplateTests this._variables.Set("myVar", "BAR"); var template = "foo-{{function $myVar}}-baz"; - var target = (BasicPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); + var target = (KernelPromptTemplate)this._factory.Create(template, new PromptTemplateConfig()); var context = this.MockContext(); // Act diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/PromptTemplateEngineTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/PromptTemplateEngineTests.cs similarity index 95% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/PromptTemplateEngineTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/PromptTemplateEngineTests.cs index 3fc9491e75..0360865cd1 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/PromptTemplateEngineTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/PromptTemplateEngineTests.cs @@ -12,21 +12,21 @@ using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Services; -using Microsoft.SemanticKernel.TemplateEngine.Basic; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Moq; -using SemanticKernel.Extensions.UnitTests.XunitHelpers; +using SemanticKernel.UnitTests.XunitHelpers; using Xunit; using Xunit.Abstractions; -namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt; +namespace SemanticKernel.UnitTests.TemplateEngine; [Obsolete("Use BasicPromptTemplateFactory instead. This will be removed in a future release.")] [EditorBrowsable(EditorBrowsableState.Never)] public sealed class PromptTemplateEngineTests { private const string DateFormat = "M/d/yyyy"; - private readonly BasicPromptTemplateEngine _target; + private readonly KernelPromptTemplateEngine _target; private readonly ContextVariables _variables; private readonly Mock _functions; private readonly ITestOutputHelper _logger; @@ -38,7 +38,7 @@ public sealed class PromptTemplateEngineTests public PromptTemplateEngineTests(ITestOutputHelper testOutputHelper) { this._logger = testOutputHelper; - this._target = new BasicPromptTemplateEngine(TestConsoleLogger.LoggerFactory); + this._target = new KernelPromptTemplateEngine(TestConsoleLogger.LoggerFactory); this._variables = new ContextVariables(Guid.NewGuid().ToString("X")); this._functions = new Mock(); this._kernel = new Mock(); @@ -216,7 +216,7 @@ public sealed class PromptTemplateEngineTests [Description("Slogan"), SKName("slogan")] string slogan, [Description("Date"), SKName("date")] DateTime date) { - var dateStr = date.ToString(PromptTemplateEngineTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } @@ -249,7 +249,7 @@ public sealed class PromptTemplateEngineTests [Description("Slogan"), SKName("slogan")] string slogan, [Description("Date"), SKName("date")] DateTime date) { - var dateStr = date.ToString(PromptTemplateEngineTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } @@ -278,7 +278,7 @@ public sealed class PromptTemplateEngineTests [Description("Date"), SKName("date")] DateTime date) { this._logger.WriteLine("MyFunction call received, name: {0}, age: {1}, slogan: {2}, date: {3}", name, age, slogan, date); - var dateStr = date.ToString(PromptTemplateEngineTests.DateFormat, CultureInfo.InvariantCulture); + var dateStr = date.ToString(DateFormat, CultureInfo.InvariantCulture); return $"[{dateStr}] {name} ({age}): \"{slogan}\""; } diff --git a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/TemplateTokenizerTests.cs b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/TemplateTokenizerTests.cs similarity index 98% rename from dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/TemplateTokenizerTests.cs rename to dotnet/src/SemanticKernel.UnitTests/TemplateEngine/TemplateTokenizerTests.cs index 53e36f3046..5806aeda6a 100644 --- a/dotnet/src/Extensions/Extensions.UnitTests/TemplateEngine/Prompt/TemplateTokenizerTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/TemplateEngine/TemplateTokenizerTests.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft. All rights reserved. using Microsoft.SemanticKernel.Diagnostics; -using Microsoft.SemanticKernel.TemplateEngine.Basic; -using Microsoft.SemanticKernel.TemplateEngine.Basic.Blocks; +using Microsoft.SemanticKernel.TemplateEngine; +using Microsoft.SemanticKernel.TemplateEngine.Blocks; using Xunit; namespace SemanticKernel.Extensions.UnitTests.TemplateEngine.Prompt;