forked from microsoft/chat-copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
54 lines (42 loc) · 1.68 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
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Microsoft. All rights reserved.
using System;
using CopilotChat.Shared;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.KernelMemory;
using Microsoft.KernelMemory.Diagnostics;
// ********************************************************
// ************** SETUP ***********************************
// ********************************************************
var builder = WebApplication.CreateBuilder();
IKernelMemory memory =
new KernelMemoryBuilder(builder.Services)
.FromAppSettings()
.WithCustomOcr(builder.Configuration)
.Build();
builder.Services.AddSingleton(memory);
builder.Services.AddApplicationInsightsTelemetry();
var app = builder.Build();
DateTimeOffset start = DateTimeOffset.UtcNow;
// Simple ping endpoint
app.MapGet("/", () =>
{
var uptime = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - start.ToUnixTimeSeconds();
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var message = $"Memory pipeline is running. Uptime: {uptime} secs.";
if (!string.IsNullOrEmpty(environment))
{
message += $" Environment: {environment}";
}
return Results.Ok(message);
});
// ********************************************************
// ************** START ***********************************
// ********************************************************
app.Logger.LogInformation(
"Starting Chat Copilot Memory pipeline service, .NET Env: {0}, Log Level: {1}",
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"),
app.Logger.GetLogLevelName());
app.Run();