Files
llm-pii-poc/src/PiiRedaction.TestHarness.Wpf/DependencyInjection/ServiceCollectionExtensions.cs

45 lines
1.8 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.AI;
using PiiRedaction.TestHarness.Wpf.Services;
using PiiRedaction.Core.Abstractions;
using PiiRedaction.Core.Configuration;
using PiiRedaction.Core.Detection;
using PiiRedaction.Core.Redaction;
using PiiRedaction.Core.Sanitization;
using PiiRedaction.Infrastructure.Llm;
using PiiRedaction.Infrastructure.Onnx;
namespace PiiRedaction.TestHarness.Wpf.DependencyInjection;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddPiiRedactionServices(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<INerLogService, NerLogService>();
services.Configure<PiiRedactionOptions>(configuration.GetSection(PiiRedactionOptions.SectionName));
services.AddSingleton<DomainRulePiiDetector>();
services.AddSingleton<RegexPiiDetector>();
services.AddSingleton<OnnxNerPiiDetector>();
services.AddSingleton<IPiiDetector>(provider => new CompositePiiDetector(
[
provider.GetRequiredService<DomainRulePiiDetector>(),
provider.GetRequiredService<RegexPiiDetector>(),
provider.GetRequiredService<OnnxNerPiiDetector>()
]));
services.AddSingleton<IPiiRedactor, PlaceholderPiiRedactor>();
services.AddSingleton<IPromptSanitizer, PromptSanitizer>();
services.AddSingleton<EnglishOnnxNerRunner>();
services.AddSingleton<TamilOnnxNerRunner>();
services.AddSingleton<IOnnxNerModelRunner, RoutingOnnxNerModelRunner>();
services.AddSingleton<IChatClient, MockChatClient>();
services.AddSingleton<ILlmPromptService, MockLlmPromptService>();
return services;
}
}