GuardContentBlock
Defined in: src/types/messages.ts:765
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:783
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:771
Discriminator for guard content.
readonly optional text: GuardContentText;Defined in: src/types/messages.ts:776
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:781
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:803
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:803 |
guardContent.text? | { qualifiers: GuardQualifier[]; text: string; } | Text content with evaluation qualifiers. | src/types/messages.ts:752 |
guardContent.text.qualifiers | GuardQualifier[] | Qualifiers that specify how this content should be evaluated. | src/types/messages.ts:721 |
guardContent.text.text | string | The text content to be evaluated. | src/types/messages.ts:726 |
guardContent.image? | { format: GuardImageFormat; source: { bytes: string; }; } | Image content with evaluation qualifiers. | src/types/messages.ts:757 |
guardContent.image.format | GuardImageFormat | Image format. | src/types/messages.ts:736 |
guardContent.image.source | { bytes: string; } | Image source (bytes only). | src/types/messages.ts:741 |
guardContent.image.source.bytes | string | - | src/types/messages.ts:712 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSONfromJSON()
Section titled “fromJSON()”static fromJSON(data): GuardContentBlock;Defined in: src/types/messages.ts:824
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