----------------------
Yes, there is a way to update a Knowledge Graph in LlamaIndex without remaking it completely. You can add new nodes and relationships to the graph manually using the
upsert_triplet_and_node
method. This method allows you to add new triplets (subject, relationship, object) and associate them with a specific node.
Here is an example of how you can do this:
# for node 0
node_0_tups = [
("author", "worked on", "writing"),
("author", "worked on", "programming"),
]
for tup in node_0_tups:
index.upsert_triplet_and_node(tup, nodes[0])
# for node 1
node_1_tups = [
("Interleaf", "made software for", "creating documents"),
("Interleaf", "added", "scripting language"),
("software", "generate", "web sites"),
]
for tup in node_1_tups:
index.upsert_triplet_and_node(tup, nodes[1])
In this example, new triplets are being added to nodes 0 and 1. The
upsert_triplet_and_node
method updates the existing node if it already exists, or inserts a new node if it doesn't.
You can find more details in the
LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------