File tree Expand file tree Collapse file tree
MaIN.Domain/Configuration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using MaIN . Core . Hub ;
22using MaIN . Core . Interfaces ;
33using MaIN . Core . Services ;
4+ using MaIN . Domain . Configuration ;
45using MaIN . Services ;
56using MaIN . Services . Services ;
67using MaIN . Services . Services . Abstract ;
@@ -14,9 +15,10 @@ public static class Bootstrapper
1415{
1516 public static IServiceCollection AddMaIN (
1617 this IServiceCollection services ,
17- IConfiguration configuration )
18+ IConfiguration configuration ,
19+ Action < MaINSettings > ? configureSettings = null )
1820 {
19- services . ConfigureMaIN ( configuration ) ;
21+ services . ConfigureMaIN ( configuration , configureSettings ) ;
2022 services . AddAIHub ( ) ;
2123 return services ;
2224 }
Original file line number Diff line number Diff line change @@ -5,11 +5,18 @@ namespace MaIN.Domain.Configuration;
55
66public class MaINSettings
77{
8+ public BackendType BackendType { get ; set ; } = BackendType . Self ;
89 public string ? ModelsPath { get ; set ; }
910 public string ? ImageGenUrl { get ; set ; }
10- public string ? OllamaUrl { get ; set ; }
11+ public string ? OpenAiKey { get ; set ; }
1112 public MongoDbSettings ? MongoDbSettings { get ; set ; }
1213 public FileSystemSettings ? FileSystemSettings { get ; set ; }
1314 public SqliteSettings ? SqliteSettings { get ; set ; }
1415 public SqlSettings ? SqlSettings { get ; set ; }
16+ }
17+
18+ public enum BackendType
19+ {
20+ Self = 0 ,
21+ OpenAi = 1
1522}
Original file line number Diff line number Diff line change @@ -12,9 +12,19 @@ namespace MaIN.Services;
1212
1313public static class Bootstrapper
1414{
15- public static IServiceCollection ConfigureMaIN ( this IServiceCollection serviceCollection , IConfiguration configuration )
15+ public static IServiceCollection ConfigureMaIN (
16+ this IServiceCollection serviceCollection ,
17+ IConfiguration configuration ,
18+ Action < MaINSettings > ? configureSettings = null )
1619 {
17- serviceCollection . Configure < MaINSettings > ( configuration . GetSection ( MainSectionName ) ) ;
20+ // Load settings from configuration
21+ var settings = configuration . GetSection ( MainSectionName ) . Get < MaINSettings > ( ) ?? new MaINSettings ( ) ;
22+
23+ // Apply additional configuration if provided
24+ configureSettings ? . Invoke ( settings ) ;
25+
26+ // Register the updated settings
27+ serviceCollection . AddSingleton ( settings ) ;
1828
1929 serviceCollection . AddSingleton < IChatService , ChatService > ( ) ;
2030 serviceCollection . AddSingleton < IAgentService , AgentService > ( ) ;
Original file line number Diff line number Diff line change 5252 PropertyNamingPolicy = JsonNamingPolicy . CamelCase
5353} ) ;
5454
55-
5655app . MapPost ( "/api/agents/{agentId}/process" , async ( HttpContext context ,
5756 [ FromServices ] IAgentService agentService ,
5857 string agentId ,
You can’t perform that action at this time.
0 commit comments