-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathProgram.cs
31 lines (26 loc) · 1.95 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
var configuration = new ConfigurationBuilder()
.AddUserSecrets<Program>()
.Build();
string apiKey = configuration["AzureOpenAI:ApiKey"];
string deploymentName = configuration["AzureOpenAI:DeploymentName"];
string endpoint = configuration["AzureOpenAI:Endpoint"];
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(deploymentName, endpoint, apiKey)
.Build();
KernelArguments kernelArguments = new()
{
{ "question", "Which type of services does Contoso Electronics provide?" },
{ "firstName", "Matteo" },
{ "context", @"Contoso Electronics is a leader in the aerospace industry, providing advanced electronic components for both commercial and military aircraft.
We specialize in creating cutting edge systems that are both reliable and efficient. Our mission is to provide the highest quality aircraft components to our customers,
while maintaining a commitment to safety and excellence. We are proud to have built a strong reputation in the aerospace industry and strive to continually
improve our products and services. Our experienced team of engineers and technicians are dedicated to providing the best products and services to our customers.
With our commitment to excellence, we are sure to remain a leader in the aerospace industry for years to come" }
};
#pragma warning disable SKEXP0040 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var prompty = kernel.CreateFunctionFromPromptyFile("basic.prompty");
#pragma warning restore SKEXP0040 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var result = await prompty.InvokeAsync<string>(kernel, kernelArguments);
Console.WriteLine(result);