-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (63 loc) · 1.97 KB
/
Program.cs
File metadata and controls
78 lines (63 loc) · 1.97 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using api_process_runner_api.Helpers;
using api_process_runner_api.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing.Constraints;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
string _apiDeploymentName = Helper.GetEnvironmentVariable("ApiDeploymentName");
string _apiEndpoint = Helper.GetEnvironmentVariable("ApiEndpoint");
string _apiKey = Helper.GetEnvironmentVariable("ApiKey");
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Add the Semantic Kernel as a transient service
builder.Services.AddTransient<Kernel>(s =>
{
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
_apiDeploymentName,
_apiEndpoint,
_apiKey
);
return builder.Build();
});
builder.Services.AddSingleton<IChatCompletionService>(sp =>
sp.GetRequiredService<Kernel>().GetRequiredService<IChatCompletionService>());
builder.Services.AddSingleton<UploadedFilesRequest>(provider =>
{
return new UploadedFilesRequest
{
AddressFilename = "Hospital-Shelters.20231107.csv",
EppicFilename = "EPPIC.20231107.CSV",
GiactFilename = "GIACT202131107.CSV",
SiebelFilename = "Siebel.20231107.CSV"
};
});
builder.Services.AddSingleton<StepsLogFile>(provider =>
{
return new StepsLogFile
{
FileName = LogFileGenerator.GenerateLogFileName()
};
});
builder.Services.AddSingleton<JobStatus>(provider =>
{
return new JobStatus
{
Status = "Not Started"
};
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();