Interface SafetyFilter
public interface SafetyFilter
Pre-flight gate that inspects messages before they're sent to the
model. Implementations may call a moderation API, run a local
profanity match, or anything else. Returning a non-null reason
blocks the chat call and propagates an
LlmException whose
LlmException.getType() is INVALID_REQUEST.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SafetyFilterA built-in filter that allows everything. -
Method Summary
Modifier and TypeMethodDescriptioncheck(List<ChatMessage> messages) Returnsnullto allow the call, or a human-readable reason string to block it.
-
Field Details
-
ALLOW_ALL
A built-in filter that allows everything. Useful as a default or as a base for composition. UseSafetyFilters.openai(key)(incom.codename1.ai.filtersor a separate cn1lib) for the OpenAI Moderation gate.
-
-
Method Details
-
check
Returnsnullto allow the call, or a human-readable reason string to block it.- Parameters:
messages- immutable request conversation- Returns:
nullto allow submission, otherwise the rejection reason
-