Skip to main content

Class: BaseNode<T>

Generic abstract class for retrievable nodes

Type parameters

NameType
Textends Metadata = Metadata

Hierarchy

Constructors

constructor

new BaseNode<T>(init?)

Type parameters

NameType
Textends Metadata = Metadata

Parameters

NameType
init?Partial<BaseNode<T>>

Defined in

packages/core/src/Node.ts:62

Properties

embedding

Optional embedding: number[]

Defined in

packages/core/src/Node.ts:53


excludedEmbedMetadataKeys

excludedEmbedMetadataKeys: string[] = []

Defined in

packages/core/src/Node.ts:57


excludedLlmMetadataKeys

excludedLlmMetadataKeys: string[] = []

Defined in

packages/core/src/Node.ts:58


hash

hash: string = ""

Defined in

packages/core/src/Node.ts:60


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.

Defined in

packages/core/src/Node.ts:52


metadata

metadata: T

Defined in

packages/core/src/Node.ts:56


relationships

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

Defined in

packages/core/src/Node.ts:59

Accessors

childNodes

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

Returns

undefined | RelatedNodeInfo<T>[]

Defined in

packages/core/src/Node.ts:114


nextNode

get nextNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Defined in

packages/core/src/Node.ts:94


parentNode

get parentNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Defined in

packages/core/src/Node.ts:104


prevNode

get prevNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Defined in

packages/core/src/Node.ts:82


sourceNode

get sourceNode(): undefined | RelatedNodeInfo<T>

Returns

undefined | RelatedNodeInfo<T>

Defined in

packages/core/src/Node.ts:72

Methods

asRelatedNodeInfo

asRelatedNodeInfo(): RelatedNodeInfo<T>

Returns

RelatedNodeInfo<T>

Defined in

packages/core/src/Node.ts:136


clone

clone(): BaseNode<Metadata>

Returns

BaseNode<Metadata>

Defined in

packages/core/src/Node.ts:153


generateHash

Abstract generateHash(): string

Returns

string

Defined in

packages/core/src/Node.ts:126


getContent

Abstract getContent(metadataMode): string

Parameters

NameType
metadataModeMetadataMode

Returns

string

Defined in

packages/core/src/Node.ts:68


getEmbedding

getEmbedding(): number[]

Returns

number[]

Defined in

packages/core/src/Node.ts:128


getMetadataStr

Abstract getMetadataStr(metadataMode): string

Parameters

NameType
metadataModeMetadataMode

Returns

string

Defined in

packages/core/src/Node.ts:69


getType

Abstract getType(): ObjectType

Returns

ObjectType

Defined in

packages/core/src/Node.ts:66


setContent

Abstract setContent(value): void

Parameters

NameType
valueany

Returns

void

Defined in

packages/core/src/Node.ts:70


toJSON

toJSON(): Record<string, any>

Called by built in JSON.stringify (see https://javascript.info/json) Properties are read-only as they are not deep-cloned (not necessary for stringification).

Returns

Record<string, any>

See

toMutableJSON - use to return a mutable JSON instead

Defined in

packages/core/src/Node.ts:149


toMutableJSON

toMutableJSON(): Record<string, any>

Converts the object to a JSON representation. Properties can be safely modified as a deep clone of the properties are created.

Returns

Record<string, any>

  • The JSON representation of the object.

Defined in

packages/core/src/Node.ts:162