Skip to content

Commit

Permalink
Merge commit '7b6e7e50' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Jul 24, 2023
2 parents c77d71a + 7b6e7e5 commit a6d9df8
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
25 changes: 25 additions & 0 deletions NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear.sln
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel" Version="0.17.230718.1-preview" />
</ItemGroup>

</Project>
73 changes: 73 additions & 0 deletions NekeaducurKernemgemjaceyear/NekeaducurKernemgemjaceyear/Program.cs
Original file line number Diff line number Diff line change
@@ -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<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
var message = formatter(state,exception);
Console.WriteLine(message);
}

public bool IsEnabled(LogLevel logLevel)
{
return true;
}

public IDisposable BeginScope<TState>(TState state)
{
return this;
}

public void Dispose()
{
}
}

0 comments on commit a6d9df8

Please sign in to comment.