.NET API
TraconContentGuardBuilderExtensions
Tracon.Core.dllChain extensions that turn on content inspection.
public static class TraconContentGuardBuilderExtensionsInheritance
Section titled “Inheritance”object ← TraconContentGuardBuilderExtensions
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”This is an extension method, not a member of ITraconBuilder: adding a member to the interface is a breaking change after release; adding an extension method is not.
Methods
Section titled “Methods”AddContentGuard<TGuard>(ITraconBuilder)
Section titled “ AddContentGuard<TGuard>(ITraconBuilder)”Registers your own IContentGuard implementation.
public static ITraconBuilder AddContentGuard<TGuard>(this ITraconBuilder builder) where TGuard : class, IContentGuardParameters
Section titled “Parameters”builder ITraconBuilder
The configuration chain.
Returns
Section titled “Returns”The chain, for further configuration.
Type Parameters
Section titled “Type Parameters”TGuard
The guard type.
Remarks
Section titled “Remarks”Multiple guards can be registered; all of them run in sequence and the strictest decision wins.
builder.AddTracon() .AddPatternContentGuard() .AddContentGuard<CustomerNameGuard>();Exceptions
Section titled “Exceptions”builder is null.
AddContentGuard(ITraconBuilder, IContentGuard)
Section titled “ AddContentGuard(ITraconBuilder, IContentGuard)”Registers a configured IContentGuard instance.
public static ITraconBuilder AddContentGuard(this ITraconBuilder builder, IContentGuard guard)Parameters
Section titled “Parameters”builder ITraconBuilder
The configuration chain.
guard IContentGuard
The guard instance.
Returns
Section titled “Returns”The chain, for further configuration.
Remarks
Section titled “Remarks”Multiple guards can be registered; all of them run in sequence and the strictest decision wins. The caller owns the instance and any resources it holds.
Exceptions
Section titled “Exceptions”A parameter is null.
AddContentGuard(ITraconBuilder, Func<IServiceProvider, IContentGuard>)
Section titled “ AddContentGuard(ITraconBuilder, Func<IServiceProvider, IContentGuard>)”Registers an IContentGuard factory.
public static ITraconBuilder AddContentGuard(this ITraconBuilder builder, Func<IServiceProvider, IContentGuard> factory)Parameters
Section titled “Parameters”builder ITraconBuilder
The configuration chain.
factory Func<IServiceProvider, IContentGuard>
The factory that creates the guard.
Returns
Section titled “Returns”The chain, for further configuration.
Remarks
Section titled “Remarks”The container owns the produced singleton. The factory must not capture a scoped dependency because the result outlives that scope.
Exceptions
Section titled “Exceptions”A parameter is null.
AddPatternContentGuard(ITraconBuilder, Action<PatternContentGuardOptions>?)
Section titled “ AddPatternContentGuard(ITraconBuilder, Action<PatternContentGuardOptions>?)”Registers Tracon’s built-in pattern-based content guard.
public static ITraconBuilder AddPatternContentGuard(this ITraconBuilder builder, Action<PatternContentGuardOptions>? configure = null)Parameters
Section titled “Parameters”builder ITraconBuilder
The configuration chain.
configure Action<PatternContentGuardOptions>?
Pattern and denied-term settings.
Returns
Section titled “Returns”The chain, for further configuration.
Remarks
Section titled “Remarks”This call is the no-surprises rule’s gate. AddTracon alone
registers no guard, and the inspection wrapper is never added to
the model pipeline. Without this call no prompt is inspected, no response
is inspected, and no cost is paid.
The built-in guard carries no rules by default: PatternContentGuardOptions.MaskedPii is PiiPatterns.None and PatternContentGuardOptions.DeniedTerms is empty. Which pattern family to turn on is an explicit choice; turning them all on at once compounds the false-positive risk.
The same settings are also read from the Tracon:ContentGuard:Pattern
configuration section; if that section is present the guard is already
registered by AddTracon and this call is redundant (the
registration uses TryAddEnumerable, so it is never added twice).
builder.AddTracon() .AddPatternContentGuard(options => { options.MaskedPii = PiiPatterns.CreditCard | PiiPatterns.Email; options.DeniedTerms.Add("secret-project"); });Exceptions
Section titled “Exceptions”builder is null.