Skip to content

Commit

Permalink
Add basic semantic kernel program
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeline committed Jan 21, 2025
1 parent de04b1c commit ee0dc0f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
30 changes: 30 additions & 0 deletions semantic_kernel/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// See https://aka.ms/new-console-template for more information

using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;

// Semantic kernel initialization
var kernel = Kernel
.CreateBuilder()
.AddOpenAIChatCompletion(
// modelId: "llama-3.2-3b-instruct",
modelId: "phi-3.1-mini-128k-instruct",
apiKey: null,
endpoint: new Uri("http://localhost:1234/v1")
)
.Build();

// var prompt = "Write a short poem about cats";
var prompt = "Rewrite the input as something that would be said by a cat {{$input}}";

var function = kernel.CreateFunctionFromPrompt(prompt, new OpenAIPromptExecutionSettings
{
TopP = 0.5,
MaxTokens = 1000
});
var response = await kernel.InvokeAsync(function, new()
{
["input"] = "Tell david that I'm going to finish the business plan by the end of the week."
});

Console.WriteLine(response);
14 changes: 14 additions & 0 deletions semantic_kernel/semantic_kernel.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel" Version="1.33.0" />
</ItemGroup>

</Project>

0 comments on commit ee0dc0f

Please sign in to comment.