Skip to main content

Class: TextNode

TextNode is the default node type for text. Most common node type in LlamaIndex.TS

Hierarchy

Constructors

constructor

new TextNode(init?)

Parameters

NameType
init?Partial<TextNode>

Overrides

BaseNode.constructor

Defined in

Node.ts:157

Properties

embedding

Optional embedding: number[]

Inherited from

BaseNode.embedding

Defined in

Node.ts:46


endCharIdx

Optional endCharIdx: number

Defined in

Node.ts:152


excludedEmbedMetadataKeys

excludedEmbedMetadataKeys: string[] = []

Inherited from

BaseNode.excludedEmbedMetadataKeys

Defined in

Node.ts:50


excludedLlmMetadataKeys

excludedLlmMetadataKeys: string[] = []

Inherited from

BaseNode.excludedLlmMetadataKeys

Defined in

Node.ts:51


hash

hash: string = ""

Inherited from

BaseNode.hash

Defined in

Node.ts:53


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

BaseNode.id_

Defined in

Node.ts:45


metadata

metadata: Record<string, any> = {}

Inherited from

BaseNode.metadata

Defined in

Node.ts:49


metadataSeparator

metadataSeparator: string = "\n"

Defined in

Node.ts:155


relationships

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

Inherited from

BaseNode.relationships

Defined in

Node.ts:52


startCharIdx

Optional startCharIdx: number

Defined in

Node.ts:151


text

text: string = ""

Defined in

Node.ts:150

Accessors

childNodes

get childNodes(): undefined | RelatedNodeInfo[]

Returns

undefined | RelatedNodeInfo[]

Inherited from

BaseNode.childNodes

Defined in

Node.ts:107


nextNode

get nextNode(): undefined | RelatedNodeInfo

Returns

undefined | RelatedNodeInfo

Inherited from

BaseNode.nextNode

Defined in

Node.ts:87


parentNode

get parentNode(): undefined | RelatedNodeInfo

Returns

undefined | RelatedNodeInfo

Inherited from

BaseNode.parentNode

Defined in

Node.ts:97


prevNode

get prevNode(): undefined | RelatedNodeInfo

Returns

undefined | RelatedNodeInfo

Inherited from

BaseNode.prevNode

Defined in

Node.ts:75


sourceNode

get sourceNode(): undefined | RelatedNodeInfo

Returns

undefined | RelatedNodeInfo

Inherited from

BaseNode.sourceNode

Defined in

Node.ts:65

Methods

asRelatedNodeInfo

asRelatedNodeInfo(): RelatedNodeInfo

Returns

RelatedNodeInfo

Inherited from

BaseNode.asRelatedNodeInfo

Defined in

Node.ts:129


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

Overrides

BaseNode.generateHash

Defined in

Node.ts:173


getContent

getContent(metadataMode?): string

Parameters

NameTypeDefault value
metadataModeMetadataModeMetadataMode.NONE

Returns

string

Overrides

BaseNode.getContent

Defined in

Node.ts:187


getEmbedding

getEmbedding(): number[]

Returns

number[]

Inherited from

BaseNode.getEmbedding

Defined in

Node.ts:121


getMetadataStr

getMetadataStr(metadataMode): string

Parameters

NameType
metadataModeMetadataMode

Returns

string

Overrides

BaseNode.getMetadataStr

Defined in

Node.ts:192


getNodeInfo

getNodeInfo(): Object

Returns

Object

NameType
endundefined | number
startundefined | number

Defined in

Node.ts:219


getText

getText(): string

Returns

string

Defined in

Node.ts:223


getType

getType(): ObjectType

Returns

ObjectType

Overrides

BaseNode.getType

Defined in

Node.ts:183


setContent

setContent(value): void

Parameters

NameType
valuestring

Returns

void

Overrides

BaseNode.setContent

Defined in

Node.ts:213


toJSON

toJSON(): Record<string, any>

Used with built in JSON.stringify

Returns

Record<string, any>

Inherited from

BaseNode.toJSON

Defined in

Node.ts:141