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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String combineMessages(List<UserMessage> userMessages) Combines multiple user messages into a single string for validation.
      ValidationResult validate(List<UserMessage> userMessages, Blackboard blackboard) Validate a list of user messages from a conversation.
      ValidationResult validate(MultimodalContent content, Blackboard blackboard) Validate multimodal content containing text and potentially images.
      • Methods inherited from class com.embabel.agent.api.validation.ContentValidator

        getDescription, getName, validate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 validate
        blackboard - 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 validate
        blackboard - the blackboard context
        Returns:

        validation result indicating success or failure