diff --git a/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.sln b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.sln new file mode 100644 index 0000000000..0fdc0361de --- /dev/null +++ b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33723.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NekeaducurKernemgemjaceyear", "NekeaducurKernemgemjaceyear\NekeaducurKernemgemjaceyear.csproj", "{F6DDB7CA-5769-457E-BBE5-6E3843CB18F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F6DDB7CA-5769-457E-BBE5-6E3843CB18F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6DDB7CA-5769-457E-BBE5-6E3843CB18F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6DDB7CA-5769-457E-BBE5-6E3843CB18F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6DDB7CA-5769-457E-BBE5-6E3843CB18F9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BE2ED2A5-4C03-42AE-8B66-C4EE4C7B1438} + EndGlobalSection +EndGlobal diff --git a/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.csproj b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.csproj new file mode 100644 index 0000000000..c9149ae590 --- /dev/null +++ b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/Program.cs b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/Program.cs new file mode 100644 index 0000000000..90e00d26f4 --- /dev/null +++ b/NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/Program.cs @@ -0,0 +1,73 @@ +// See https://aka.ms/new-console-template for more information + +using Microsoft.Extensions.Logging; +using Microsoft.SemanticKernel; + +var builder = new KernelBuilder(); + +builder.WithAzureChatCompletionService("GPT35", // Azure OpenAI Deployment Name + "https://lindexi.openai.azure.com/", // Azure OpenAI Endpoint + args[0]); // Azure OpenAI Key + +//builder.WithAzureTextCompletionService( +// "GPT35", // Azure OpenAI Deployment Name +// "https://lindexi.openai.azure.com/", // Azure OpenAI Endpoint +// args[0]); // Azure OpenAI Key + +// Alternative using OpenAI +//builder.WithOpenAITextCompletionService( +// "text-davinci-003", // OpenAI Model name +// "...your OpenAI API Key..."); // OpenAI API Key +builder.WithLogger(new Logger()); + +var kernel = builder.Build(); + +var prompt = @"{{$input}} + +One line TLDR with the fewest words."; + +var summarize = kernel.CreateSemanticFunction(prompt); + +string text1 = @" +1st Law of Thermodynamics - Energy cannot be created or destroyed. +2nd Law of Thermodynamics - For a spontaneous process, the entropy of the universe increases. +3rd Law of Thermodynamics - A perfect crystal at zero Kelvin has zero entropy."; + +string text2 = @" +1. An object at rest remains at rest, and an object in motion remains in motion at constant speed and in a straight line unless acted on by an unbalanced force. +2. The acceleration of an object depends on the mass of the object and the amount of force applied. +3. Whenever one object exerts a force on another object, the second object exerts an equal and opposite on the first."; + +var result = await summarize.InvokeAsync(text1); +Console.WriteLine(result); + +Console.WriteLine(await summarize.InvokeAsync(text2)); + +// Output: +// Energy conserved, entropy increases, zero entropy at 0K. +// Objects move in response to forces. + +Console.WriteLine("Hello, World!"); + +class Logger : ILogger, IDisposable +{ + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) + { + var message = formatter(state,exception); + Console.WriteLine(message); + } + + public bool IsEnabled(LogLevel logLevel) + { + return true; + } + + public IDisposable BeginScope(TState state) + { + return this; + } + + public void Dispose() + { + } +} \ No newline at end of file