Add PII redaction POC for secure LLM prompting.
Implements detect-redact-sanitize pipeline with regex, domain rules, and ONNX NER before the LLM boundary, plus NUnit tests and Xenovex push documentation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
42
tests/TestSupport.Shared/RealNerModelFixture.cs
Normal file
42
tests/TestSupport.Shared/RealNerModelFixture.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using PiiRedaction.Core.Configuration;
|
||||
using PiiRedaction.Infrastructure.Onnx;
|
||||
|
||||
namespace PiiRedaction.Tests.Shared;
|
||||
|
||||
/// <summary>
|
||||
/// Reuses a single <see cref="OnnxNerModelRunner"/> per fixture for performance.
|
||||
/// Skips all tests in the class when the ONNX model is missing or cannot be loaded.
|
||||
/// </summary>
|
||||
public abstract class RealNerModelFixture
|
||||
{
|
||||
protected OnnxNerModelRunner Runner { get; private set; } = null!;
|
||||
|
||||
protected string ModelPath { get; private set; } = null!;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetUpRealModel()
|
||||
{
|
||||
ModelPath = RealNerModelPaths.ResolveRepoModelPath();
|
||||
if (!File.Exists(ModelPath))
|
||||
{
|
||||
Assert.Ignore(RealNerModelPaths.ModelMissingMessage);
|
||||
}
|
||||
|
||||
var options = Options.Create(new PiiRedactionOptions { OnnxModelPath = ModelPath });
|
||||
Runner = new OnnxNerModelRunner(options, NullLogger<OnnxNerModelRunner>.Instance);
|
||||
|
||||
if (!Runner.IsModelAvailable)
|
||||
{
|
||||
Runner.Dispose();
|
||||
Assert.Ignore(RealNerModelPaths.ModelMissingMessage);
|
||||
}
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void OneTimeTearDownRealModel()
|
||||
{
|
||||
Runner?.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user