-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
43 lines (35 loc) · 1.48 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
// Copyright (c) Microsoft. All rights reserved.
using AIPlugins.AzureFunctions.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Models;
const string DefaultSemanticFunctionsFolder = "Prompts";
string semanticFunctionsFolder = Environment.GetEnvironmentVariable("SEMANTIC_SKILLS_FOLDER") ?? DefaultSemanticFunctionsFolder;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
services
.AddScoped<IKernel>((providers) =>
{
// This will be called each time a new Kernel is needed
// Get a logger instance
ILogger<IKernel> logger = providers
.GetRequiredService<ILoggerFactory>()
.CreateLogger<IKernel>();
// Register your AI Providers...
var appSettings = AppSettings.LoadSettings();
IKernel kernel = new KernelBuilder()
.WithChatCompletionService(appSettings.Kernel)
.WithLogger(logger)
.Build();
// Load your semantic functions...
kernel.ImportPromptsFromDirectory(appSettings.AIPlugin.NameForModel, semanticFunctionsFolder);
return kernel;
})
.AddScoped<IAIPluginRunner, AIPluginRunner>();
})
.Build();
host.Run();