Skip to main content

Class: ImageGuardrail

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:141

A guard over an input's images (visionInputs), on the input stage. Built with ImageGuardrail.create.

Example​

const images = ImageGuardrail.create({ id: 'images', checks: [hashCheck, visionCheck], requireMatch: true, sequential: true });
const decision = await moderateContent({ text, images: uploads }, { guards: [images, textGuard], context });

Implements​

Properties​

config​

readonly config: GuardrailConfig

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:148

Fail-closed, never a sanitizer, with the guard's deadline; sequential when asked; reasonCodes is the guard's two fixed codes (IMAGE_LIMIT, IMAGE_CHECK_UNAVAILABLE) and every check's list.

Implementation of​

IGuardrailService.config


id​

readonly id: string

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:143

The id given to create(), a word.

Implementation of​

IGuardrailService.id


stages​

readonly stages: readonly ("output" | "input")[]

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:150

The guard judges what a person sends: the input stage.

Implementation of​

IGuardrailService.stages

Methods​

evaluateInput()​

evaluateInput(payload): Promise<GuardrailEvaluationResult | null>

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:328

Judges the input's images. An input with no images answers null.

Parameters​

payload​

GuardrailInputPayload

The input and its context; context.vendorSignal stops further classify checks once aborted, and deadlineSignal (the dispatcher's deadline, which a required guard's spec may set shorter than timeoutMs) stops every further capture and check.

Returns​

Promise<GuardrailEvaluationResult | null>

A check's block, else a hold, else an image refused as unavailable, else a flag, else null.

Implementation of​

IGuardrailService.evaluateInput


create()​

static create(options): ImageGuardrail

Defined in: packages/agentos/src/safety/guardrails/builtin/ImageGuardrail.ts:185

Builds the guard, or throws when the list could send an image to a model unchecked or could judge nothing: an empty list, no classify check, a classify check before a match check, a match check with onError: 'skip', an onError other than refuse or skip, a reason code that is not a word, and, with requireMatch, no match check.

Parameters​

options​

ImageGuardrailOptions

The id, the checks in order, and the guard's limits.

Returns​

ImageGuardrail

The guard.

Throws​

TypeError when the options cannot make a guard that judges every image it lets through.