fix python settings.
This commit is contained in:
parent
d9e775a0f4
commit
13e9ef0067
|
|
@ -0,0 +1,11 @@
|
|||
namespace BotSharp.Abstraction.Interpreters.Settings;
|
||||
|
||||
public class InterpreterSettings
|
||||
{
|
||||
public PythonInterpreterSetting Python { get; set; }
|
||||
}
|
||||
|
||||
public class PythonInterpreterSetting
|
||||
{
|
||||
public string PythonDLL { get; set; }
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ using BotSharp.Abstraction.Settings;
|
|||
using BotSharp.Abstraction.Options;
|
||||
using BotSharp.Abstraction.Messaging.JsonConverters;
|
||||
using BotSharp.Abstraction.Users.Settings;
|
||||
using BotSharp.Abstraction.Interpreters.Settings;
|
||||
|
||||
namespace BotSharp.Core;
|
||||
|
||||
|
|
@ -13,6 +14,12 @@ public static class BotSharpCoreExtensions
|
|||
{
|
||||
public static IServiceCollection AddBotSharpCore(this IServiceCollection services, IConfiguration config, Action<BotSharpOptions>? configOptions = null)
|
||||
{
|
||||
var interpreterSettings = new InterpreterSettings();
|
||||
config.Bind("Interpreter", interpreterSettings);
|
||||
services.AddSingleton(x => interpreterSettings);
|
||||
|
||||
services.AddSingleton<DistributedLocker>();
|
||||
|
||||
services.AddScoped<ISettingService, SettingService>();
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
services.AddSingleton<DistributedLocker>();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using BotSharp.Logger;
|
|||
using BotSharp.Plugin.ChatHub;
|
||||
using Serilog;
|
||||
using BotSharp.Abstraction.Messaging.JsonConverters;
|
||||
using Python.Runtime;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
|
@ -42,11 +41,4 @@ 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();
|
||||
app.Run();
|
||||
|
|
@ -299,6 +299,12 @@
|
|||
}
|
||||
},
|
||||
|
||||
"Interpreter": {
|
||||
"Python": {
|
||||
"PythonDLL": "C:/Users/xxx/AppData/Local/Programs/Python/Python311/python311.dll"
|
||||
}
|
||||
},
|
||||
|
||||
"PluginLoader": {
|
||||
"Assemblies": [
|
||||
"BotSharp.Core",
|
||||
|
|
|
|||
Loading…
Reference in a new issue