For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
PlaygroundDiscordStatusDashboardSign Up >
DocumentationSDK ReferenceGraphiti
DocumentationSDK ReferenceGraphiti
  • Getting Started
    • Welcome
    • Overview
    • Quick Start
    • MCP Server
  • Configuration
    • LLM Configuration
    • Neo4j Configuration
    • FalkorDB Configuration
    • AWS Neptune Configuration
    • Kuzu DB Configuration
  • Core Concepts
    • Adding Episodes
    • Custom Entity and Edge Types
    • Communities
    • Graph Namespacing
  • Working with Data
    • Searching
    • CRUD Operations
    • Adding Fact Triples
  • Integrations
    • LangGraph Agent
  • Other
    • Telemetry
LogoLogo
PlaygroundDiscordStatusDashboardSign Up >
Working with Data

Adding Fact Triples

How to add fact triples to your Graphiti graph
Was this page helpful?
Previous

Using LangGraph and Graphiti

Building an agent with LangChain's LangGraph and Graphiti
Next
Built with

A “fact triple” consists of two nodes and an edge between them, where the edge typically contains some fact. You can manually add a fact triple of your choosing to the graph like this:

1from graphiti_core.nodes import EpisodeType, EntityNode
2from graphiti_core.edges import EntityEdge
3import uuid
4from datetime import datetime
5
6source_name = "Bob"
7target_name = "bananas"
8source_uuid = "some existing UUID" # This is an existing node, so we use the existing UUID obtained from Neo4j Desktop
9target_uuid = str(uuid.uuid4()) # This is a new node, so we create a new UUID
10edge_name = "LIKES"
11edge_fact = "Bob likes bananas"
12
13
14source_node = EntityNode(
15 uuid=source_uuid,
16 name=source_name,
17 group_id=""
18)
19target_node = EntityNode(
20 uuid=target_uuid,
21 name=target_name,
22 group_id=""
23)
24edge = EntityEdge(
25 group_id="",
26 source_node_uuid=source_uuid,
27 target_node_uuid=target_uuid,
28 created_at=datetime.now(),
29 name=edge_name,
30 fact=edge_fact
31)
32
33await graphiti.add_triplet(source_node, edge, target_node)

When you add a fact triple, Graphiti will attempt to deduplicate your passed in nodes and edge with the already existing nodes and edges in the graph. If there are no duplicates, it will add them as new nodes and edges.

Also, you can avoid constructing EntityEdge or EntityNode objects manually by using the results of a Graphiti search (see Searching the Graph).