forked from microsoft/kernel-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
37 lines (27 loc) · 1019 Bytes
/
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
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.KernelMemory;
using Microsoft.KernelMemory.Service.AspNetCore;
var webAppBuilder = WebApplication.CreateBuilder(args);
// Add services to your ASP.NET app
webAppBuilder.Services.AddControllers();
// Add Kernel Memory to your ASP.NET app
webAppBuilder.AddKernelMemory(kmBuilder =>
{
// Configure Kernel Memory here if needed
kmBuilder
.WithOpenAIDefaults(Environment.GetEnvironmentVariable("OPENAI_API_KEY")!)
.WithCustomImageOcr(new MyOcrEngine());
}
);
// Build ASP.NET app
var wepApp = webAppBuilder.Build();
// Typical ASP.NET app setup
wepApp.UseHttpsRedirection();
wepApp.UseAuthorization();
wepApp.MapControllers();
// Optional: add Kernel Memory web endpoints
wepApp.AddGetIndexesEndpoint("/km/"); // GET /km/indexes
// Start ASP.NET app
wepApp.Run();
// Try GET http://localhost:5000/memory => see MemoryController
// Try GET http://localhost:5000/km/indexes => list of KM indexes