forked from matthewbolanos/sk-v1-proposal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
67 lines (56 loc) · 2.09 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.SemanticKernel.AI.ChatCompletion;
using Microsoft.SemanticKernel.Handlebars;
string OpenAIApiKey = Env.Var("OpenAI:ApiKey")!;
string BingApiKey = Env.Var("Bing:ApiKey")!;
string currentDirectory = Directory.GetCurrentDirectory();
// Initialize the required functions and services for the kernel
IChatCompletion gpt35Turbo = new OpenAIChatCompletion("gpt-3.5-turbo-1106", OpenAIApiKey);
OllamaGeneration ollamaGeneration = new("wizard-math");
// Create plugins
IPlugin mathPlugin = new Plugin(
name: "Math",
functions: NativeFunction.GetFunctionsFromObject(new Math())
);
Plugin ollamaGenerationPlugin = new Plugin(
name: "Math",
functions: new () {
SemanticFunction.GetFunctionFromYaml(currentDirectory + "/Plugins/Ollama/Math.prompt.yaml")
}
);
IPlugin searchPlugin = new Plugin(
name: "Search",
functions: NativeFunction.GetFunctionsFromObject(new Search(BingApiKey))
);
// Create a researcher
IPlugin researcher = AssistantKernel.FromConfiguration(
currentDirectory + "/Assistants/Researcher.agent.yaml",
aiServices: new () { gpt35Turbo, },
plugins: new () { searchPlugin }
);
// Create a mathmatician
IPlugin mathmatician = AssistantKernel.FromConfiguration(
currentDirectory + "/Assistants/Mathmatician.agent.yaml",
aiServices: new () { gpt35Turbo, ollamaGeneration },
plugins: new () { mathPlugin }
);
// Create a Project Manager
AssistantKernel projectManager = AssistantKernel.FromConfiguration(
currentDirectory + "/Assistants/ProjectManager.agent.yaml",
aiServices: new () { gpt35Turbo },
plugins: new () { researcher, mathmatician }
);
IThread thread = await projectManager.CreateThreadAsync();
while(true) {
// Get user input
Console.Write("User > ");
thread.AddUserMessageAsync(Console.ReadLine());
// Run the thread using the project manager kernel
var result = await projectManager.RunAsync(thread);
// Print the results
var messages = result.GetValue<List<ModelMessage>>();
foreach(ModelMessage message in messages)
{
Console.WriteLine("Project Manager > " + message);
}
}