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.8 kB

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