You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using LLama.Web.Common;
  2. using LLama.Web.Hubs;
  3. using LLama.Web.Services;
  4. var builder = WebApplication.CreateBuilder(args);
  5. // Add services to the container.
  6. var mvcBuilder = builder.Services.AddRazorPages();
  7. if (builder.Environment.IsDevelopment())
  8. {
  9. mvcBuilder.AddRazorRuntimeCompilation();
  10. builder.Configuration.AddJsonFile("appSettings.Local.json");
  11. }
  12. builder.Services.AddSignalR();
  13. builder.Logging.ClearProviders();
  14. builder.Services.AddLogging((loggingBuilder) => loggingBuilder.SetMinimumLevel(LogLevel.Trace).AddConsole());
  15. // Load InteractiveOptions
  16. builder.Services.AddOptions<LLamaOptions>()
  17. .PostConfigure(x => x.Initialize())
  18. .BindConfiguration(nameof(LLamaOptions));
  19. // Services DI
  20. builder.Services.AddHostedService<ModelLoaderService>();
  21. builder.Services.AddSingleton<IModelService, ModelService>();
  22. builder.Services.AddSingleton<IModelSessionService, ModelSessionService>();
  23. var app = builder.Build();
  24. // Configure the HTTP request pipeline.
  25. if (!app.Environment.IsDevelopment())
  26. {
  27. app.UseExceptionHandler("/Error");
  28. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  29. app.UseHsts();
  30. }
  31. app.UseHttpsRedirection();
  32. app.UseStaticFiles();
  33. app.UseRouting();
  34. app.UseAuthorization();
  35. app.MapRazorPages();
  36. app.MapHub<SessionConnectionHub>(nameof(SessionConnectionHub));
  37. app.Run();