-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (81 loc) · 3.52 KB
/
Copy pathProgram.cs
File metadata and controls
97 lines (81 loc) · 3.52 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using System.Net.Http.Headers;
using prototype3.Data;
using prototype3.Controllers;
using prototype3.Models;
using PromptToBoolMvc.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(connectionString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
builder.Services.AddControllersWithViews();
// Bind the "OpenSearch" section from appsettings.json
builder.Services.Configure<OpenSearchSettings>(
builder.Configuration.GetSection("OpenSearch"));
// Typed client for OpenSearchController
builder.Services.AddHttpClient<OpenSearchController>(httpClient =>
{
// Base URL of your OpenSearch 3 node or load balancer
httpClient.BaseAddress = new Uri("http://10.13.44.83:9200/");
// Add auth headers here if needed:
// client.DefaultRequestHeaders.Authorization =
// new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("user:pass")));
});
// Typed client for OpenSearchController
builder.Services.AddHttpClient<GeoHexSearchController>(httpClient =>
{
// Base URL of your OpenSearch 3 node or load balancer
httpClient.BaseAddress = new Uri("http://10.13.44.83:9200/");
// Add auth headers here if needed:
// client.DefaultRequestHeaders.Authorization =
// new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("user:pass")));
});
builder.Services.AddControllersWithViews()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.WriteIndented = true;
});
builder.Services.AddHttpClient("vllm", (IServiceProvider sp, HttpClient client) =>
{
IConfiguration cfg = sp.GetRequiredService<IConfiguration>();
string? baseUrl = cfg["Vllm:BaseUrl"];
client.BaseAddress = new Uri(baseUrl ?? "http://localhost:8000");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
});
builder.Services.AddHttpClient("boolapi", (IServiceProvider sp, HttpClient client) =>
{
IConfiguration cfg = sp.GetRequiredService<IConfiguration>();
string? baseUrl = cfg["BooleanApi:BaseUrl"];
client.BaseAddress = new Uri(baseUrl ?? "http://localhost:5005");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
});
builder.Services.AddSingleton<LlmBoolService>();
builder.Services.AddSingleton<BooleanSearchService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();
app.MapControllers();
app.Run();