-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
45 lines (35 loc) · 1.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Import the Kernel class from the Microsoft.SemanticKernel namespace
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Plugins;
// Add configuration
var config = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json")
.AddUserSecrets<Program>()
.Build();
// Create a new Kernel Builder
var builder = Kernel.CreateBuilder();
// Add OpenAI Chat Completion to the builder
builder.AddAzureOpenAIChatCompletion(
config["deployment"],
config["endpoint"],
config["apiKey"]
);
builder.Plugins.AddFromType<SocialPlugin>();
builder.Plugins.AddFromPromptDirectory("./Plugins/FactmanPlugin");
// Build the kernel using the configured builder
var kernel = builder.Build();
var commonMyth = await kernel.InvokeAsync("FactmanPlugin", "FindMyth");
var bustedMyth = await kernel.InvokeAsync("FactmanPlugin", "BustMyth", new() {
{ "myth", commonMyth }
});
var optimizeResponse = await kernel.InvokeAsync("FactmanPlugin", "AdaptMessage", new() {
{ "input", bustedMyth },
{ "platform", "twitter" }
});
var socialMediaPost = await kernel.InvokeAsync("SocialPlugin", "Post", new() {
{ "platform", "x" },
{ "message", optimizeResponse }
});
Console.WriteLine(socialMediaPost);