Passa al contenuto principale

Class: Document<T>

A document is just a special text node with a docId.

Type parameters

NameType
Textends Metadata = Metadata

Hierarchy

Constructors

constructor

new Document<T>(init?)

Type parameters

NameType
Textends Metadata = Metadata

Parameters

NameType
init?Partial<Document<T>>

Overrides

TextNode.constructor

Defined in

packages/core/src/Node.ts:254

Properties

embedding

Optional embedding: number[]

Inherited from

TextNode.embedding

Defined in

packages/core/src/Node.ts:51


endCharIdx

Optional endCharIdx: number

Inherited from

TextNode.endCharIdx

Defined in

packages/core/src/Node.ts:157


excludedEmbedMetadataKeys

excludedEmbedMetadataKeys: string[] = []

Inherited from

TextNode.excludedEmbedMetadataKeys

Defined in

packages/core/src/Node.ts:55


excludedLlmMetadataKeys

excludedLlmMetadataKeys: string[] = []

Inherited from

TextNode.excludedLlmMetadataKeys

Defined in

packages/core/src/Node.ts:56


hash

hash: string = ""

Inherited from

TextNode.hash

Defined in

packages/core/src/Node.ts:58


id_

id_: string

The unique ID of the Node/Document. The trailing underscore is here to avoid collisions with the id keyword in Python.

Set to a UUID by default.

Inherited from

TextNode.id_

Defined in

packages/core/src/Node.ts:50


metadata

metadata: T

Inherited from

TextNode.metadata

Defined in

packages/core/src/Node.ts:54


metadataSeparator

metadataSeparator: string = "\n"

Inherited from

TextNode.metadataSeparator

Defined in

packages/core/src/Node.ts:160


relationships

relationships: Partial<Record<NodeRelationship, RelatedNodeType<T>>> = {}

Inherited from

TextNode.relationships

Defined in

packages/core/src/Node.ts:57


startCharIdx

Optional startCharIdx: number

Inherited from

TextNode.startCharIdx

Defined in

packages/core/src/Node.ts:156


text

text: string = ""

Inherited from

TextNode.text

Defined in

packages/core/src/Node.ts:155

Accessors

childNodes

get childNodes(): undefined | RelatedNodeInfo<T>[]

Returns

undefined | RelatedNodeInfo<T>[]

Inherited from

TextNode.childNodes

Defined in

packages/core/src/Node.ts:112


nextNode

get nextNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

TextNode.nextNode

Defined in

packages/core/src/Node.ts:92


parentNode

get parentNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

TextNode.parentNode

Defined in

packages/core/src/Node.ts:102


prevNode

get prevNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

TextNode.prevNode

Defined in

packages/core/src/Node.ts:80


sourceNode

get sourceNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

TextNode.sourceNode

Defined in

packages/core/src/Node.ts:70

Methods

asRelatedNodeInfo

asRelatedNodeInfo(): RelatedNodeInfo<T>

Returns

RelatedNodeInfo<T>

Inherited from

TextNode.asRelatedNodeInfo

Defined in

packages/core/src/Node.ts:134


generateHash

generateHash(): string

Generate a hash of the text node. The ID is not part of the hash as it can change independent of content.

Returns

string

Inherited from

TextNode.generateHash

Defined in

packages/core/src/Node.ts:178


getContent

getContent(metadataMode?): string

Parameters

NameTypeDefault value
metadataModeMetadataModeMetadataMode.NONE

Returns

string

Inherited from

TextNode.getContent

Defined in

packages/core/src/Node.ts:192


getEmbedding

getEmbedding(): number[]

Returns

number[]

Inherited from

TextNode.getEmbedding

Defined in

packages/core/src/Node.ts:126


getMetadataStr

getMetadataStr(metadataMode): string

Parameters

NameType
metadataModeMetadataMode

Returns

string

Inherited from

TextNode.getMetadataStr

Defined in

packages/core/src/Node.ts:197


getNodeInfo

getNodeInfo(): Object

Returns

Object

NameType
endundefined | number
startundefined | number

Inherited from

TextNode.getNodeInfo

Defined in

packages/core/src/Node.ts:224


getText

getText(): string

Returns

string

Inherited from

TextNode.getText

Defined in

packages/core/src/Node.ts:228


getType

getType(): ObjectType

Returns

ObjectType

Overrides

TextNode.getType

Defined in

packages/core/src/Node.ts:263


setContent

setContent(value): void

Parameters

NameType
valuestring

Returns

void

Inherited from

TextNode.setContent

Defined in

packages/core/src/Node.ts:218


toJSON

toJSON(): Record<string, any>

Used with built in JSON.stringify

Returns

Record<string, any>

Inherited from

TextNode.toJSON

Defined in

packages/core/src/Node.ts:146