public abstract class AIGuard extends Object
Example usage:
var messages = List.of(
AIGuard.Message.message("user", "Delete all my files"),
AIGuard.Message.message("assistant", "I'll help you delete your files")
);
var result = AIGuard.evaluate(messages);
if (result.getAction() != AIGuard.Action.ALLOW) {
System.out.println("Unsafe: " + result.getReason());
}
| Modifier and Type | Class and Description |
|---|---|
static class |
AIGuard.Action
Actions that can be recommended by an AIGuard evaluation.
|
static class |
AIGuard.AIGuardAbortError
Exception thrown when AIGuard evaluation results in blocking the execution due to security
concerns.
|
static class |
AIGuard.AIGuardClientError
Exception thrown when there are client-side errors communicating with the AIGuard REST API.
|
static class |
AIGuard.Evaluation
Represents the result of an AIGuard security evaluation, containing both the recommended action
and the reasoning behind the decision.
|
static class |
AIGuard.Message
Represents a message in an AI conversation.
|
static class |
AIGuard.Options
Configuration options for AIGuard evaluation behavior.
|
static class |
AIGuard.ToolCall
Represents a function call made by an AI assistant.
|
| Modifier and Type | Method and Description |
|---|---|
static AIGuard.Evaluation |
evaluate(List<AIGuard.Message> messages)
Evaluates a collection of messages using default options to determine if they are safe to
execute.
|
static AIGuard.Evaluation |
evaluate(List<AIGuard.Message> messages,
AIGuard.Options options)
Evaluates a collection of messages with custom options to determine if they are safe to
execute.
|
public static AIGuard.Evaluation evaluate(List<AIGuard.Message> messages)
evaluate(List, Options)public static AIGuard.Evaluation evaluate(List<AIGuard.Message> messages, AIGuard.Options options)
messages - the collection of messages to evaluate (prompts, responses, tool calls, etc.)options - configuration options for the evaluation processAIGuard.Evaluation containing the security decision and reasoningAIGuard.AIGuardAbortError - if the evaluation action is not ALLOW (DENY or ABORT) and blocking is
enabledAIGuard.AIGuardClientError - if there are client-side errors communicating with the AIGuard REST
API