forked from microsoft/kernel-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
28 lines (20 loc) · 942 Bytes
/
Program.cs
File metadata and controls
28 lines (20 loc) · 942 Bytes
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
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.KernelMemory;
/* The following code shows how to create a custom handler, attached
* to a queue and listening for work to do. You can also add multiple handlers
* the same way.
*/
// Usual .NET web app builder
var appBuilder = WebApplication.CreateBuilder();
/* ... setup your handler dependencies ... */
// builder.Services.AddSingleton...
// builder.Services.AddTransient...
// Define the handlers to host
appBuilder.Services.AddHandlerAsHostedService<MyHandler>("mypipelinestep");
// builder.Services.AddHandlerAsHostedService<MyHandler2>("mypipelinestep-2");
// builder.Services.AddHandlerAsHostedService<MyHandler3>("mypipelinestep-3");
// Inject memory dependencies
var _ = new KernelMemoryBuilder(appBuilder.Services).WithOpenAIDefaults(Env.Var("OPENAI_API_KEY")).Complete();
// Build and run .NET web app as usual
var app = appBuilder.Build();
app.Run();