GuardContentBlock
Defined in: src/types/messages.ts:747
Guard content block for guardrail evaluation. Marks content that should be evaluated by guardrails for safety, grounding, or other policies. Can be used in both message content and system prompts.
Implements
Section titled “Implements”GuardContentBlockDataJSONSerializable<{guardContent:Serialized<GuardContentBlockData>; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GuardContentBlock(data): GuardContentBlock;Defined in: src/types/messages.ts:765
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | GuardContentBlockData |
Returns
Section titled “Returns”GuardContentBlock
Properties
Section titled “Properties”readonly type: "guardContentBlock";Defined in: src/types/messages.ts:753
Discriminator for guard content.
readonly optional text: GuardContentText;Defined in: src/types/messages.ts:758
Text content with evaluation qualifiers.
Implementation of
Section titled “Implementation of”image?
Section titled “image?”readonly optional image: GuardContentImage;Defined in: src/types/messages.ts:763
Image content with evaluation qualifiers.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): { guardContent: { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string; }; }; };};Defined in: src/types/messages.ts:785
Serializes the GuardContentBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Uint8Array image bytes are encoded as base64 string.
Returns
Section titled “Returns”{ guardContent: { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string; }; }; };}| Name | Type | Description | Defined in |
|---|---|---|---|
guardContent | { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string; }; }; } | - | src/types/messages.ts:785 |
guardContent.text? | { qualifiers: GuardQualifier[]; text: string; } | Text content with evaluation qualifiers. | src/types/messages.ts:734 |
guardContent.text.qualifiers | GuardQualifier[] | Qualifiers that specify how this content should be evaluated. | src/types/messages.ts:703 |
guardContent.text.text | string | The text content to be evaluated. | src/types/messages.ts:708 |
guardContent.image? | { format: GuardImageFormat; source: { bytes: string; }; } | Image content with evaluation qualifiers. | src/types/messages.ts:739 |
guardContent.image.format | GuardImageFormat | Image format. | src/types/messages.ts:718 |
guardContent.image.source | { bytes: string; } | Image source (bytes only). | src/types/messages.ts:723 |
guardContent.image.source.bytes | string | - | src/types/messages.ts:694 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSONfromJSON()
Section titled “fromJSON()”static fromJSON(data): GuardContentBlock;Defined in: src/types/messages.ts:806
Creates a GuardContentBlock instance from its wrapped data format. Base64-encoded image bytes are decoded back to Uint8Array.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | { guardContent: { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; }; }; } | Wrapped GuardContentBlockData to deserialize (accepts both string and Uint8Array for image bytes) |
data.guardContent | { text?: { qualifiers: GuardQualifier[]; text: string; }; image?: { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; }; } | - |
data.guardContent.text? | { qualifiers: GuardQualifier[]; text: string; } | Text content with evaluation qualifiers. |
data.guardContent.text.qualifiers | GuardQualifier[] | Qualifiers that specify how this content should be evaluated. |
data.guardContent.text.text | string | The text content to be evaluated. |
data.guardContent.image? | { format: GuardImageFormat; source: { bytes: string | Uint8Array<ArrayBufferLike>; }; } | Image content with evaluation qualifiers. |
data.guardContent.image.format | GuardImageFormat | Image format. |
data.guardContent.image.source | { bytes: string | Uint8Array<ArrayBufferLike>; } | Image source (bytes only). |
data.guardContent.image.source.bytes | string | Uint8Array<ArrayBufferLike> | - |
Returns
Section titled “Returns”GuardContentBlock
GuardContentBlock instance