Skip to main content

Node Types

Graphiti uses four primary node types to represent different elements in the knowledge graph. All nodes inherit from the base Node class and share common fields for identification, grouping, and timestamps.

Base Node

The abstract base class that all node types inherit from.
uuid
str
required
Unique identifier for the node. Automatically generated using UUID4 if not provided.
name
str
required
Name of the node.
group_id
str
required
Partition identifier for the graph. Used to organize nodes into logical groups or namespaces.
labels
list[str]
List of labels applied to the node. Default: empty list.
created_at
datetime
Timestamp of when the node was created. Automatically set to current UTC time if not provided.

EntityNode

Represents entities extracted from episodes, such as people, places, organizations, or concepts.

Fields

Inherits all fields from Node, plus:
name_embedding
list[float] | None
Vector embedding of the entity name, used for semantic similarity searches. Generated using the configured embedder client.
summary
str
Regional summary of surrounding edges and relationships. Default: empty string.
attributes
dict[str, Any]
Additional attributes of the node. Content depends on node labels and can store custom properties extracted from episodes.

Methods

generate_name_embedding
async method
Generates and stores the name embedding for this entity.Parameters:
  • embedder: EmbedderClient - The embedder client to use for generating embeddings
Returns: list[float] - The generated embedding vector
load_name_embedding
async method
Loads the name embedding from the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance
Raises: NodeNotFoundError if the node doesn’t exist
save
async method
Persists the entity node to the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance

Class Methods

get_by_uuid
async classmethod
Retrieves a single entity node by UUID.Parameters:
  • driver: GraphDriver
  • uuid: str
Returns: EntityNodeRaises: NodeNotFoundError if not found
get_by_uuids
async classmethod
Retrieves multiple entity nodes by UUIDs.Parameters:
  • driver: GraphDriver
  • uuids: list[str]
Returns: list[EntityNode]
get_by_group_ids
async classmethod
Retrieves entity nodes by group IDs with optional pagination.Parameters:
  • driver: GraphDriver
  • group_ids: list[str]
  • limit: int | None - Maximum number of results (optional)
  • uuid_cursor: str | None - UUID cursor for pagination (optional)
  • with_embeddings: bool - Whether to include embeddings (default: False)
Returns: list[EntityNode]

EpisodicNode

Represents raw episodes (events or documents) that have been processed into the knowledge graph.

Fields

Inherits all fields from Node, plus:
source
EpisodeType
required
The type/source of the episode. See EpisodeType for available values.
source_description
str
required
Description of the data source for this episode.
content
str
required
Raw episode data/content.
valid_at
datetime
required
Timestamp of when the original document was created or when the event occurred.
entity_edges
list[str]
List of entity edge UUIDs referenced in this episode. Default: empty list.

Methods

save
async method
Persists the episodic node to the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance

Class Methods

get_by_uuid
async classmethod
Retrieves a single episodic node by UUID.Parameters:
  • driver: GraphDriver
  • uuid: str
Returns: EpisodicNodeRaises: NodeNotFoundError if not found
get_by_uuids
async classmethod
Retrieves multiple episodic nodes by UUIDs.Parameters:
  • driver: GraphDriver
  • uuids: list[str]
Returns: list[EpisodicNode]
get_by_group_ids
async classmethod
Retrieves episodic nodes by group IDs with optional pagination.Parameters:
  • driver: GraphDriver
  • group_ids: list[str]
  • limit: int | None - Maximum number of results (optional)
  • uuid_cursor: str | None - UUID cursor for pagination (optional)
Returns: list[EpisodicNode]
get_by_entity_node_uuid
async classmethod
Retrieves all episodic nodes that mention a specific entity.Parameters:
  • driver: GraphDriver
  • entity_node_uuid: str - UUID of the entity node
Returns: list[EpisodicNode]

CommunityNode

Represents a community or cluster of related entities in the knowledge graph.

Fields

Inherits all fields from Node, plus:
name_embedding
list[float] | None
Vector embedding of the community name, used for semantic similarity searches.
summary
str
Regional summary of member nodes and their relationships. Default: empty string.

Methods

save
async method
Persists the community node to the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance
generate_name_embedding
async method
Generates and stores the name embedding for this community.Parameters:
  • embedder: EmbedderClient - The embedder client to use for generating embeddings
Returns: list[float] - The generated embedding vector
load_name_embedding
async method
Loads the name embedding from the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance
Raises: NodeNotFoundError if the node doesn’t exist

Class Methods

get_by_uuid
async classmethod
Retrieves a single community node by UUID.Parameters:
  • driver: GraphDriver
  • uuid: str
Returns: CommunityNodeRaises: NodeNotFoundError if not found
get_by_uuids
async classmethod
Retrieves multiple community nodes by UUIDs.Parameters:
  • driver: GraphDriver
  • uuids: list[str]
Returns: list[CommunityNode]
get_by_group_ids
async classmethod
Retrieves community nodes by group IDs with optional pagination.Parameters:
  • driver: GraphDriver
  • group_ids: list[str]
  • limit: int | None - Maximum number of results (optional)
  • uuid_cursor: str | None - UUID cursor for pagination (optional)
Returns: list[CommunityNode]

SagaNode

Represents a saga, which is a collection of related episodes forming a narrative thread.

Fields

Inherits all fields from Node with no additional fields.

Methods

save
async method
Persists the saga node to the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance
delete
async method
Deletes the saga node from the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance

Class Methods

get_by_uuid
async classmethod
Retrieves a single saga node by UUID.Parameters:
  • driver: GraphDriver
  • uuid: str
Returns: SagaNodeRaises: NodeNotFoundError if not found
get_by_uuids
async classmethod
Retrieves multiple saga nodes by UUIDs.Parameters:
  • driver: GraphDriver
  • uuids: list[str]
Returns: list[SagaNode]
get_by_group_ids
async classmethod
Retrieves saga nodes by group IDs with optional pagination.Parameters:
  • driver: GraphDriver
  • group_ids: list[str]
  • limit: int | None - Maximum number of results (optional)
  • uuid_cursor: str | None - UUID cursor for pagination (optional)
Returns: list[SagaNode]

Common Node Operations

All node types support the following operations:

Delete Operations

delete
async method
Deletes the node and its relationships from the graph database.Parameters:
  • driver: GraphDriver - The graph driver instance
delete_by_group_id
async classmethod
Deletes all nodes of this type within a group.Parameters:
  • driver: GraphDriver
  • group_id: str
  • batch_size: int - Number of nodes to delete per batch (default: 100)
delete_by_uuids
async classmethod
Deletes multiple nodes by their UUIDs.Parameters:
  • driver: GraphDriver
  • uuids: list[str]
  • batch_size: int - Number of nodes to delete per batch (default: 100)

Helper Functions

create_entity_node_embeddings
async function
Batch generates embeddings for multiple entity nodes.Parameters:
  • embedder: EmbedderClient
  • nodes: list[EntityNode]
Filters out nodes with empty names and generates embeddings for the remaining nodes in batch.
  • Edge Types - Learn about edge types that connect nodes
  • Episodes - Learn about episode types and processing
  • Search - Search across nodes in the knowledge graph

Build docs developers (and LLMs) love