JGuardrails

org.llm4s.javaapi.JGuardrails
object JGuardrails

The built-in guardrails, for an agent built with Llm4s.agentBuilder (#2476).

Llm4s.agentBuilder("support", client)
   .inputGuardrails(List.of(JGuardrails.length(1, 10_000), JGuardrails.profanity()))
   .outputGuardrails(List.of(JGuardrails.json()))

A guardrail that fails blocks the turn: it ends with status BLOCKED, naming the guardrail and its reason, and the conversation stays usable. No factory throws: an invalid argument (a negative length, a null pattern) gives a guardrail that the agent's build() refuses with a failed result naming the argument.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

An answer that is valid JSON. It checks answers only, so it goes in outputGuardrails.

An answer that is valid JSON. It checks answers only, so it goes in outputGuardrails.

Attributes

def length(min: Int, max: Int): JGuardrail

Text between min and max characters long, inclusive. min must be at least 0 and max at least min.

Text between min and max characters long, inclusive. min must be at least 0 and max at least min.

Attributes

Text that contains no word of the built-in word list, compared without regard to case. The list is deliberately minimal: use it as an example of a word filter, not as a production profanity list.

Text that contains no word of the built-in word list, compared without regard to case. The list is deliberately minimal: use it as an example of a word filter, not as a production profanity list.

Attributes

def regex(pattern: String): JGuardrail

Text that contains a match of pattern, in java.util.regex syntax; an unsafe or invalid pattern fails every text.

Text that contains a match of pattern, in java.util.regex syntax; an unsafe or invalid pattern fails every text.

Attributes

def regex(pattern: String, errorMessage: String): JGuardrail

regex(pattern), reporting errorMessage when the text does not match.

regex(pattern), reporting errorMessage when the text does not match.

Attributes