Skip to content

DocumentBlock

Defined in: src/types/media.ts:428

Document content block.

new DocumentBlock(data): DocumentBlock;

Defined in: src/types/media.ts:459

| Parameter | Type | | --------- | -------------------------------------------- | | data | DocumentBlockData |

DocumentBlock

readonly type: "documentBlock";

Defined in: src/types/media.ts:432

Discriminator for document content.


readonly name: string;

Defined in: src/types/media.ts:437

Document name.

DocumentBlockData.name


readonly format: DocumentFormat;

Defined in: src/types/media.ts:442

Document format.

DocumentBlockData.format


readonly source: DocumentSource;

Defined in: src/types/media.ts:447

Document source.

DocumentBlockData.source


readonly optional citations?: {
enabled: boolean;
};

Defined in: src/types/media.ts:452

Citation configuration.

enabled: boolean;

DocumentBlockData.citations


readonly optional context?: string;

Defined in: src/types/media.ts:457

Context information for the document.

DocumentBlockData.context

toJSON(): {
document: {
name: string;
format: DocumentFormat;
source: | {
bytes: string;
}
| {
text: string;
}
| {
content: {
text: string;
}[];
}
| {
location: {
type: "s3";
uri: string;
bucketOwner?: string;
};
};
citations?: {
enabled: boolean;
};
context?: string;
};
};

Defined in: src/types/media.ts:504

Serializes the DocumentBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify(). Uint8Array bytes are encoded as base64 string.

{
document: {
name: string;
format: DocumentFormat;
source: | {
bytes: string;
}
| {
text: string;
}
| {
content: {
text: string;
}[];
}
| {
location: {
type: "s3";
uri: string;
bucketOwner?: string;
};
};
citations?: {
enabled: boolean;
};
context?: string;
};
}

| Name | Type | Description | Defined in | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | document | { name: string; format: DocumentFormat; source: | { bytes: string; } | { text: string; } | { content: { text: string; }[]; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; }; citations?: { enabled: boolean; }; context?: string; } | - | src/types/media.ts:504 | | document.name | string | Document name. | src/types/media.ts:402 | | document.format | DocumentFormat | Document format. | src/types/media.ts:407 | | document.source | | { bytes: string; } | { text: string; } | { content: { text: string; }[]; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | Document source. | src/types/media.ts:412 | | document.citations? | { enabled: boolean; } | Citation configuration. | src/types/media.ts:417 | | document.citations.enabled | boolean | - | src/types/media.ts:417 | | document.context? | string | Context information for the document. | src/types/media.ts:422 |

JSONSerializable.toJSON

static fromJSON(data): DocumentBlock;

Defined in: src/types/media.ts:533

Creates a DocumentBlock instance from its wrapped data format. Base64-encoded bytes are decoded back to Uint8Array.

| Parameter | Type | Description | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | data | { document: { name: string; format: DocumentFormat; source: | { bytes: string | Uint8Array<ArrayBufferLike>; } | { text: string; } | { content: { text: string; }[]; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; }; citations?: { enabled: boolean; }; context?: string; }; } | Wrapped DocumentBlockData to deserialize (accepts both string and Uint8Array for bytes) | | data.document | { name: string; format: DocumentFormat; source: | { bytes: string | Uint8Array<ArrayBufferLike>; } | { text: string; } | { content: { text: string; }[]; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; }; citations?: { enabled: boolean; }; context?: string; } | - | | data.document.name | string | Document name. | | data.document.format | DocumentFormat | Document format. | | data.document.source | | { bytes: string | Uint8Array<ArrayBufferLike>; } | { text: string; } | { content: { text: string; }[]; } | { location: { type: "s3"; uri: string; bucketOwner?: string; }; } | Document source. | | data.document.citations? | { enabled: boolean; } | Citation configuration. | | data.document.citations.enabled | boolean | - | | data.document.context? | string | Context information for the document. |

DocumentBlock

DocumentBlock instance