_Ref-Node:

节点

Node data structure.

Node is a generic data container that contains a piece of data (e.g. chunk of text, an image, a table, etc).

In comparison to a raw Document, it contains additional metadata about its relationship to other Node objects (and Document objects).

It is often used as an atomic unit of data in various indices.

class llama_index.data_structs.node.DocumentRelationship(value)

Document relationships used in Node class.

SOURCE

The node is the source document.

PREVIOUS

The node is the previous node in the document.

NEXT

The node is the next node in the document.

PARENT

The node is the parent node in the document.

CHILD

The node is a child node in the document.

class llama_index.data_structs.node.Node(text: ~typing.Optional[str] = None, doc_id: ~typing.Optional[str] = None, embedding: ~typing.Optional[~typing.List[float]] = None, doc_hash: ~typing.Optional[str] = None, extra_info: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = None, node_info: ~typing.Optional[~typing.Dict[str, ~typing.Any]] = None, relationships: ~typing.Dict[~llama_index.data_structs.node.DocumentRelationship, ~typing.Any] = <factory>)

A generic node of data.

参数
  • text (str) -- The text of the node.

  • doc_id (Optional[str]) -- The document id of the node.

  • embeddings (Optional[List[float]]) -- The embeddings of the node.

  • relationships (Dict[DocumentRelationship, Any]) -- The relationships of the node.

property child_node_ids: List[str]

Child node ids.

doc_hash: Optional[str] = None

" metadata fields - injected as part of the text shown to LLMs as context - used by vector DBs for metadata filtering

This must be a flat dictionary, and only uses str keys, and (str, int, float) values.

property extra_info_str: Optional[str]

Extra info string.

get_doc_hash() str

Get doc_hash.

get_doc_id() str

Get doc_id.

get_embedding() List[float]

Get embedding.

Errors if embedding is None.

get_node_info() Dict[str, Any]

Get node info.

get_origin_type() str

Get origin type.

get_text() str

Get text.

classmethod get_type() str

Get type.

classmethod get_types() List[str]

Get Document type.

property is_doc_id_none: bool

Check if doc_id is None.

property is_text_none: bool

Check if text is None.

property next_node_id: str

Next node id.

property parent_node_id: str

Parent node id.

property prev_node_id: str

Prev node id.

property ref_doc_id: Optional[str]

Source document id.

Extracted from the relationships field.

class llama_index.data_structs.node.NodeWithScore(node: llama_index.data_structs.node.Node, score: Optional[float] = None)