-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
37 lines (28 loc) · 1.44 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
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Ollama;
#pragma warning disable SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var semanticKernelBuilder = Kernel.CreateBuilder().AddOllamaChatCompletion(modelId: "phi3:mini", endpoint: new Uri("http://localhost:11434/"));
#pragma warning restore SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var kernel = semanticKernelBuilder.Build();
var prompt = @"You can have any conversation about any topic.
{{$history}}
The user input is:{{$input}}
";
var chat = kernel.CreateFunctionFromPrompt(prompt);
#pragma warning disable SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var settings = new OllamaPromptExecutionSettings
{
Temperature = 0.0f
};
#pragma warning restore SKEXP0070 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
while (true)
{
Console.Write("You: ");
var input = Console.ReadLine();
var arguments = new KernelArguments(settings)
{
["$input"] = input
};
var response = await chat.InvokeAsync(kernel, arguments);
Console.WriteLine($"ChatBot: {response}");
}