File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 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 ) ;
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments