Interface UserInputGuardRail
-
- All Implemented Interfaces:
-
com.embabel.agent.api.validation.ContentValidator,com.embabel.agent.api.validation.guardrails.GuardRail
public interface UserInputGuardRail implements GuardRail
Validates user inputs before LLM execution.
UserInputGuardRails provide safety checks on content that users provide to AI systems, ensuring that potentially harmful, inappropriate, or policy-violating content is detected and handled before being processed by the LLM.
This interface provides overloads for different input types while maintaining the base string validation from the GuardRail interface.
-
-
Method Summary
Modifier and Type Method Description StringcombineMessages(List<UserMessage> userMessages)Combines multiple user messages into a single string for validation. ValidationResultvalidate(List<UserMessage> userMessages, Blackboard blackboard)Validate a list of user messages from a conversation. ValidationResultvalidate(MultimodalContent content, Blackboard blackboard)Validate multimodal content containing text and potentially images. -
-
Method Detail
-
combineMessages
String combineMessages(List<UserMessage> userMessages)
Combines multiple user messages into a single string for validation.
Override this method to customize how messages are combined before validation. For example, implementations might want to:
Add separators or context markers between messages
Filter out certain message types
Apply message-specific preprocessing
- Parameters:
userMessages- the list of user messages to combine- Returns:
the combined text representation of the messages
-
validate
ValidationResult validate(List<UserMessage> userMessages, Blackboard blackboard)
Validate a list of user messages from a conversation.
This method allows validation of multi-turn user inputs and can examine the context and flow of user messages in the conversation.
Default implementation uses combineMessages to extract and combine text content from all user messages, then validates the combined text. Implementations can override combineMessages for custom message combination, or override this method entirely for more sophisticated conversation-aware validation.
- Parameters:
userMessages- the list of user messages to validateblackboard- the blackboard context- Returns:
validation result indicating success or failure
-
validate
ValidationResult validate(MultimodalContent content, Blackboard blackboard)
Validate multimodal content containing text and potentially images.
This method handles validation of content that may include both textual and visual components. The default implementation validates only the text portion, but implementations can override to provide image content analysis.
- Parameters:
content- the multimodal content to validateblackboard- the blackboard context- Returns:
validation result indicating success or failure
-
-
-
-