Skip to content

Commit 80bbe5c

Browse files
committed
Add the Semantic Kernel
1 parent 634c58d commit 80bbe5c

File tree

6 files changed

+22
-38
lines changed

6 files changed

+22
-38
lines changed
11.9 KB
Binary file not shown.
Binary file not shown.
Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,23 @@
11
using Microsoft.SemanticKernel;
2+
using System;
3+
using System.Threading.Tasks;
4+
using Microsoft.SemanticKernel.Plugins.Core;
5+
//using RepoUtils;
26

37
namespace GeneralUpdate.Bowl
48
{
59
public class BowlBootstrap
610
{
7-
public async Task Launch()
11+
public void test()
812
{
9-
var builder = new KernelBuilder();
13+
Console.WriteLine("======== Functions ========");
1014

11-
builder.WithAzureChatCompletionService(
12-
"gpt-35-turbo", // Azure OpenAI Deployment Name
13-
"https://contoso.openai.azure.com/", // Azure OpenAI Endpoint
14-
"...your Azure OpenAI Key..."); // Azure OpenAI Key
15+
// Load native plugin
16+
var text = new TextPlugin();
1517

16-
// Alternative using OpenAI
17-
//builder.WithOpenAIChatCompletionService(
18-
// "gpt-3.5-turbo", // OpenAI Model name
19-
// "...your OpenAI API Key..."); // OpenAI API Key
20-
21-
var kernel = builder.Build();
22-
23-
var prompt = @"{{$input}}
24-
25-
One line TLDR with the fewest words.";
26-
27-
var summarize = kernel.CreateSemanticFunction(prompt, maxTokens: 100);
28-
29-
string text1 = @"
30-
1st Law of Thermodynamics - Energy cannot be created or destroyed.
31-
2nd Law of Thermodynamics - For a spontaneous process, the entropy of the universe increases.
32-
3rd Law of Thermodynamics - A perfect crystal at zero Kelvin has zero entropy.";
33-
34-
string text2 = @"
35-
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.
36-
2. The acceleration of an object depends on the mass of the object and the amount of force applied.
37-
3. Whenever one object exerts a force on another object, the second object exerts an equal and opposite on the first.";
38-
39-
Console.WriteLine(await summarize.InvokeAsync(text1));
40-
41-
Console.WriteLine(await summarize.InvokeAsync(text2));
42-
43-
// Output:
44-
// Energy conserved, entropy increases, zero entropy at 0K.
45-
// Objects move in response to forces.
18+
// Use function without kernel
19+
var result = text.Uppercase("Ai4c research institute!");
20+
Console.WriteLine(result);
4621
}
4722
}
4823
}

src/WPF/GeneralUpdate.Bowl/GeneralUpdate.Bowl.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
10+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
11+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
12+
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
14+
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta1" />
1115
</ItemGroup>
1216

1317
</Project>

src/WPF/GeneralUpdate.Packet/GeneralUpdate.Packet.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@
1515
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<ProjectReference Include="..\GeneralUpdate.Bowl\GeneralUpdate.Bowl.csproj" />
20+
</ItemGroup>
21+
1822
</Project>

src/WPF/GeneralUpdate.Packet/ViewModels/MainViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using GeneralUpdate.Packet.Modules;
1+
using GeneralUpdate.Bowl;
2+
using GeneralUpdate.Packet.Modules;
23
using GeneralUpdate.Packet.MVVM;
34
using System.Collections.ObjectModel;
45
using System.Windows;

0 commit comments

Comments
 (0)