from llama_index.core import Document
from llama_index.core.schema import (
    TextNode, 
    NodeRelationship, 
    RelatedNodeInfo
)
doc = Document(text="Pierwsze zdanie. Drugie zdanie")
n1 = TextNode(text="Pierwsze zdanie", node_id=doc.doc_id)
n2 = TextNode(text="Drugie zdanie", node_id=doc.doc_id)

n1.relationships[NodeRelationship.NEXT] = n2.node_id 
n2.relationships[NodeRelationship.PREVIOUS] = n1.node_id
print(n1.relationships)
print(n2.relationships)

