forked from microsoft/semantic-kernel-starters
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
41 lines (35 loc) · 1.34 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
using System.Net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Plugins;
// Load the kernel settings
var kernelSettings = KernelSettings.LoadSettings();
// Create the host builder with logging configured from the kernel settings.
var builder = Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
logging.SetMinimumLevel(kernelSettings.LogLevel ?? LogLevel.Warning);
});
// Configure the services for the host
builder.ConfigureServices((context, services) =>
{
// Add kernel settings to the host builder
services
.AddSingleton<KernelSettings>(kernelSettings)
.AddTransient<Kernel>(serviceProvider => {
KernelBuilder builder = new();
builder.Services.AddLogging(c => c.AddDebug().SetMinimumLevel(LogLevel.Information));
builder.Services.AddChatCompletionService(kernelSettings);
builder.Plugins.AddFromType<LightPlugin>();
return builder.Build();
})
.AddHostedService<ConsoleChat>();
});
// Build and run the host. This keeps the app running using the HostedService.
var host = builder.Build();
await host.RunAsync();