Pular para o conteúdo principal

Class: TextNode<T>

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

Type parameters

NameType
Textends Metadata = Metadata

Hierarchy

Constructors

constructor

new TextNode<T>(init?)

Type parameters

NameType
Textends Metadata = Metadata

Parameters

NameType
init?Partial<TextNode<T>>

Overrides

BaseNode.constructor

Defined in

packages/core/src/Node.ts:162

Properties

embedding

Optional embedding: number[]

Inherited from

BaseNode.embedding

Defined in

packages/core/src/Node.ts:51


endCharIdx

Optional endCharIdx: number

Defined in

packages/core/src/Node.ts:157


excludedEmbedMetadataKeys

excludedEmbedMetadataKeys: string[] = []

Inherited from

BaseNode.excludedEmbedMetadataKeys

Defined in

packages/core/src/Node.ts:55


excludedLlmMetadataKeys

excludedLlmMetadataKeys: string[] = []

Inherited from

BaseNode.excludedLlmMetadataKeys

Defined in

packages/core/src/Node.ts:56


hash

hash: string = ""

Inherited from

BaseNode.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

BaseNode.id_

Defined in

packages/core/src/Node.ts:50


metadata

metadata: T

Inherited from

BaseNode.metadata

Defined in

packages/core/src/Node.ts:54


metadataSeparator

metadataSeparator: string = "\n"

Defined in

packages/core/src/Node.ts:160


relationships

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

Inherited from

BaseNode.relationships

Defined in

packages/core/src/Node.ts:57


startCharIdx

Optional startCharIdx: number

Defined in

packages/core/src/Node.ts:156


text

text: string = ""

Defined in

packages/core/src/Node.ts:155

Accessors

childNodes

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

Returns

undefined | RelatedNodeInfo<T>[]

Inherited from

BaseNode.childNodes

Defined in

packages/core/src/Node.ts:112


nextNode

get nextNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

BaseNode.nextNode

Defined in

packages/core/src/Node.ts:92


parentNode

get parentNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

BaseNode.parentNode

Defined in

packages/core/src/Node.ts:102


prevNode

get prevNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

BaseNode.prevNode

Defined in

packages/core/src/Node.ts:80


sourceNode

get sourceNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Inherited from

BaseNode.sourceNode

Defined in

packages/core/src/Node.ts:70

Methods

asRelatedNodeInfo

asRelatedNodeInfo(): RelatedNodeInfo<T>

Returns

RelatedNodeInfo<T>

Inherited from

BaseNode.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

Overrides

BaseNode.generateHash

Defined in

packages/core/src/Node.ts:178


getContent

getContent(metadataMode?): string

Parameters

NameTypeDefault value
metadataModeMetadataModeMetadataMode.NONE

Returns

string

Overrides

BaseNode.getContent

Defined in

packages/core/src/Node.ts:192


getEmbedding

getEmbedding(): number[]

Returns

number[]

Inherited from

BaseNode.getEmbedding

Defined in

packages/core/src/Node.ts:126


getMetadataStr

getMetadataStr(metadataMode): string

Parameters

NameType
metadataModeMetadataMode

Returns

string

Overrides

BaseNode.getMetadataStr

Defined in

packages/core/src/Node.ts:197


getNodeInfo

getNodeInfo(): Object

Returns

Object

NameType
endundefined | number
startundefined | number

Defined in

packages/core/src/Node.ts:224


getText

getText(): string

Returns

string

Defined in

packages/core/src/Node.ts:228


getType

getType(): ObjectType

Returns

ObjectType

Overrides

BaseNode.getType

Defined in

packages/core/src/Node.ts:188


setContent

setContent(value): void

Parameters

NameType
valuestring

Returns

void

Overrides

BaseNode.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

BaseNode.toJSON

Defined in

packages/core/src/Node.ts:146