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

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