-
Notifications
You must be signed in to change notification settings - Fork 67
/
Program.cs
37 lines (30 loc) · 1.11 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
// This file was auto-generated by ML.NET Model Builder.
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.ML;
using Microsoft.OpenApi.Models;
using Microsoft.ML.Data;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
// Configure app
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddPredictionEnginePool<GitHubIssues.ModelInput, GitHubIssues.ModelOutput>()
.FromFile("GitHubIssues.mlnet");
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Description = "Docs for my API", Version = "v1" });
});
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
// Define prediction route & handler
app.MapPost("/predict",
async (PredictionEnginePool<GitHubIssues.ModelInput, GitHubIssues.ModelOutput> predictionEnginePool, GitHubIssues.ModelInput input) =>
await Task.FromResult(predictionEnginePool.Predict(input)));
// Run app
app.Run();