using BotSharp.Core; using BotSharp.OpenAPI; using BotSharp.Logger; using BotSharp.Plugin.ChatHub; using Serilog; using BotSharp.Abstraction.Messaging.JsonConverters; using Python.Runtime; var builder = WebApplication.CreateBuilder(args); builder.Host.UseSerilog(); string[] allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get() ?? new[] { "http://0.0.0.0:5015", "https://botsharp.scisharpstack.org", "https://chat.scisharpstack.org" }; // Add BotSharp builder.Services.AddBotSharpCore(builder.Configuration, options => { options.JsonSerializerOptions.Converters.Add(new RichContentJsonConverter()); options.JsonSerializerOptions.Converters.Add(new TemplateMessageJsonConverter()); }).AddBotSharpOpenAPI(builder.Configuration, allowedOrigins, builder.Environment, true) .AddBotSharpLogger(builder.Configuration); // Add service defaults & Aspire components. builder.AddServiceDefaults(); // Add SignalR for WebSocket builder.Services.AddSignalR(); var app = builder.Build(); // Enable SignalR app.MapHub("/chatHub"); app.UseMiddleware(); // Use BotSharp app.UseBotSharp() .UseBotSharpOpenAPI(app.Environment) .UseBotSharpUI(); Runtime.PythonDLL = @"C:\Users\xxx\AppData\Local\Programs\Python\Python311\python311.dll"; PythonEngine.Initialize(); PythonEngine.BeginAllowThreads(); app.Run(); // Shut down the Python engine PythonEngine.Shutdown();