Skip to content

Commit ee0dc0f

Browse files
committed
Add basic semantic kernel program
1 parent de04b1c commit ee0dc0f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

semantic_kernel/Program.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// See https://aka.ms/new-console-template for more information
2+
3+
using Microsoft.SemanticKernel;
4+
using Microsoft.SemanticKernel.Connectors.OpenAI;
5+
6+
// Semantic kernel initialization
7+
var kernel = Kernel
8+
.CreateBuilder()
9+
.AddOpenAIChatCompletion(
10+
// modelId: "llama-3.2-3b-instruct",
11+
modelId: "phi-3.1-mini-128k-instruct",
12+
apiKey: null,
13+
endpoint: new Uri("http://localhost:1234/v1")
14+
)
15+
.Build();
16+
17+
// var prompt = "Write a short poem about cats";
18+
var prompt = "Rewrite the input as something that would be said by a cat {{$input}}";
19+
20+
var function = kernel.CreateFunctionFromPrompt(prompt, new OpenAIPromptExecutionSettings
21+
{
22+
TopP = 0.5,
23+
MaxTokens = 1000
24+
});
25+
var response = await kernel.InvokeAsync(function, new()
26+
{
27+
["input"] = "Tell david that I'm going to finish the business plan by the end of the week."
28+
});
29+
30+
Console.WriteLine(response);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.SemanticKernel" Version="1.33.0" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)