Class GuardrailRegistry
java.lang.Object
com.tnsai.quality.tracing.guardrail.GuardrailRegistry
Registry for pre-response and post-response guardrails.
Pre-response guardrails run on the input before the agent processes it. Post-response guardrails run on the input+output after the agent responds.
Thread-safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallPostResponsePass(String input, String output) Returns true if all post-response guardrails pass for the given input/output.booleanallPreResponsePass(String input) Returns true if all pre-response guardrails pass for the given input.evaluatePostResponse(String input, String output) Runs all post-response guardrails on the given input/output pair.evaluatePreResponse(String input) Runs all pre-response guardrails on the given input.Looks up a guardrail by name.Returns all post-response guardrails.Returns all pre-response guardrails.voidregisterPostResponse(Guardrail guardrail) Registers a post-response guardrail (runs on input+output after processing).voidregisterPreResponse(Guardrail guardrail) Registers a pre-response guardrail (runs on input before processing).
-
Constructor Details
-
GuardrailRegistry
public GuardrailRegistry()
-
-
Method Details
-
registerPreResponse
Registers a pre-response guardrail (runs on input before processing). -
registerPostResponse
Registers a post-response guardrail (runs on input+output after processing). -
preResponseGuardrails
Returns all pre-response guardrails. -
postResponseGuardrails
Returns all post-response guardrails. -
get
Looks up a guardrail by name.- Returns:
- the guardrail, or null if not found
-
evaluatePreResponse
Runs all pre-response guardrails on the given input.- Parameters:
input- the input text- Returns:
- list of results, one per guardrail
-
evaluatePostResponse
Runs all post-response guardrails on the given input/output pair.- Parameters:
input- the input textoutput- the output text- Returns:
- list of results, one per guardrail
-
allPreResponsePass
Returns true if all pre-response guardrails pass for the given input. -
allPostResponsePass
Returns true if all post-response guardrails pass for the given input/output.
-