| | | 1 | | using Elsa.AI.Abstractions.Contracts; |
| | | 2 | | using Elsa.AI.Host.Context; |
| | | 3 | | using Elsa.AI.Host.Options; |
| | | 4 | | using Elsa.AI.Host.Services; |
| | | 5 | | using Elsa.AI.Host.Streaming; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection; |
| | | 7 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 8 | | using Microsoft.Extensions.Hosting; |
| | | 9 | | |
| | | 10 | | // ReSharper disable once CheckNamespace |
| | | 11 | | namespace Elsa.Extensions; |
| | | 12 | | |
| | | 13 | | public static class ServiceCollectionExtensions |
| | | 14 | | { |
| | | 15 | | public static IServiceCollection AddAIHostServices(this IServiceCollection services, Action<AIHostOptions>? configur |
| | | 16 | | { |
| | 51 | 17 | | if (configureOptions != null) |
| | 12 | 18 | | services.Configure(configureOptions); |
| | | 19 | | |
| | 51 | 20 | | services.AddLogging(); |
| | 51 | 21 | | services.AddOptions<AIHostOptions>(); |
| | 51 | 22 | | services.TryAddSingleton<InMemoryAIConversationStore>(); |
| | 90 | 23 | | services.TryAddSingleton<IAIConversationStore>(sp => sp.GetRequiredService<InMemoryAIConversationStore>()); |
| | 51 | 24 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IAIContextProvider, WorkflowDefinitionContextProvider>()); |
| | 51 | 25 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IAIContextProvider, WorkflowInstanceContextProvider>()); |
| | 51 | 26 | | services.TryAddSingleton<AIContextResolver>(); |
| | 51 | 27 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, AIContextProviderValidationHostedService>( |
| | 51 | 28 | | services.TryAddSingleton<AIToolEnablementService>(); |
| | 51 | 29 | | services.TryAddSingleton<IAIToolRegistry, AIToolRegistry>(); |
| | 51 | 30 | | services.TryAddScoped<IAIOrchestrator, AIOrchestrator>(); |
| | 51 | 31 | | services.TryAddSingleton<AIStreamSessionManager>(); |
| | 51 | 32 | | services.TryAddSingleton<AIStreamEventMapper>(); |
| | 51 | 33 | | services.TryAddSingleton<AIAuditSink>(); |
| | 91 | 34 | | services.TryAddSingleton<IAIAuditSink>(sp => sp.GetRequiredService<AIAuditSink>()); |
| | | 35 | | |
| | 51 | 36 | | return services; |
| | | 37 | | } |
| | | 38 | | } |