TextNode#

pydantic model llama_index.core.schema.TextNode#

Show JSON schema
{
   "title": "TextNode",
   "description": "Base node Object.\n\nGeneric abstract interface for retrievable nodes",
   "type": "object",
   "properties": {
      "id_": {
         "title": "Id ",
         "description": "Unique ID of the node.",
         "type": "string"
      },
      "embedding": {
         "title": "Embedding",
         "description": "Embedding of the node.",
         "type": "array",
         "items": {
            "type": "number"
         }
      },
      "extra_info": {
         "title": "Extra Info",
         "description": "A flat dictionary of metadata fields",
         "type": "object"
      },
      "excluded_embed_metadata_keys": {
         "title": "Excluded Embed Metadata Keys",
         "description": "Metadata keys that are excluded from text for the embed model.",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "excluded_llm_metadata_keys": {
         "title": "Excluded Llm Metadata Keys",
         "description": "Metadata keys that are excluded from text for the LLM.",
         "type": "array",
         "items": {
            "type": "string"
         }
      },
      "relationships": {
         "title": "Relationships",
         "description": "A mapping of relationships to other node information.",
         "type": "object",
         "additionalProperties": {
            "anyOf": [
               {
                  "$ref": "#/definitions/RelatedNodeInfo"
               },
               {
                  "type": "array",
                  "items": {
                     "$ref": "#/definitions/RelatedNodeInfo"
                  }
               }
            ]
         }
      },
      "text": {
         "title": "Text",
         "description": "Text content of the node.",
         "default": "",
         "type": "string"
      },
      "start_char_idx": {
         "title": "Start Char Idx",
         "description": "Start char index of the node.",
         "type": "integer"
      },
      "end_char_idx": {
         "title": "End Char Idx",
         "description": "End char index of the node.",
         "type": "integer"
      },
      "text_template": {
         "title": "Text Template",
         "description": "Template for how text is formatted, with {content} and {metadata_str} placeholders.",
         "default": "{metadata_str}\n\n{content}",
         "type": "string"
      },
      "metadata_template": {
         "title": "Metadata Template",
         "description": "Template for how metadata is formatted, with {key} and {value} placeholders.",
         "default": "{key}: {value}",
         "type": "string"
      },
      "metadata_seperator": {
         "title": "Metadata Seperator",
         "description": "Separator between metadata fields when converting to string.",
         "default": "\n",
         "type": "string"
      },
      "class_name": {
         "title": "Class Name",
         "type": "string",
         "default": "TextNode"
      }
   },
   "definitions": {
      "ObjectType": {
         "title": "ObjectType",
         "description": "An enumeration.",
         "enum": [
            "1",
            "2",
            "3",
            "4"
         ],
         "type": "string"
      },
      "RelatedNodeInfo": {
         "title": "RelatedNodeInfo",
         "description": "Base component object to capture class names.",
         "type": "object",
         "properties": {
            "node_id": {
               "title": "Node Id",
               "type": "string"
            },
            "node_type": {
               "$ref": "#/definitions/ObjectType"
            },
            "metadata": {
               "title": "Metadata",
               "type": "object"
            },
            "hash": {
               "title": "Hash",
               "type": "string"
            },
            "class_name": {
               "title": "Class Name",
               "type": "string",
               "default": "RelatedNodeInfo"
            }
         },
         "required": [
            "node_id"
         ]
      }
   }
}

Config
  • allow_population_by_field_name: bool = True

  • validate_assignment: bool = True

Fields
field end_char_idx: Optional[int] = None#

End char index of the node.

field metadata_seperator: str = '\n'#

Separator between metadata fields when converting to string.

field metadata_template: str = '{key}: {value}'#

Template for how metadata is formatted, with {key} and {value} placeholders.

field start_char_idx: Optional[int] = None#

Start char index of the node.

field text: str = ''#

Text content of the node.

field text_template: str = '{metadata_str}\n\n{content}'#

Template for how text is formatted, with {content} and {metadata_str} placeholders.

classmethod class_name() str#

Get the class name, used as a unique ID in serialization.

This provides a key that makes serialization robust against actual class name changes.

get_content(metadata_mode: MetadataMode = MetadataMode.NONE) str#

Get object content.

get_metadata_str(mode: MetadataMode = MetadataMode.ALL) str#

Metadata info string.

get_node_info() Dict[str, Any]#

Get node info.

get_text() str#
classmethod get_type() str#

Get Object type.

set_content(value: str) None#

Set the content of the node.

property hash: str#

Get hash of node.

property node_info: Dict[str, Any]#

Get node info.

Type

Deprecated