Find answers from the community

Updated 4 months ago

Hi, I am trying to experiment with

At a glance
Hi, I am trying to experiment with custom nodes.

I tried creating a parent-child relationship like this:

child_node.relationships[NodeRelationship.PARENT] = RelatedNodeInfo(
node_id=parent_node.node_id
)

parent_node.relationships[NodeRelationship.CHILD] = RelatedNodeInfo(
node_id=child_node.node_id
)


But I keep getting the error:

ValueError: Child objects must be a list of RelatedNodeInfo objects.

When I do print(parent_node.child_nodes)

It seems I am missing something. Can someone help me out here? Thanks!

The documentation I used as a reference to write this is here: https://docs.llamaindex.ai/en/stable/module_guides/loading/documents_and_nodes/usage_nodes/

Edit: Can we only connect 1 child node at a time?

Edit 2: Nevermind, I figured it out after looking at the source code. Please ignore
L
L
4 comments
yea as the error stated, Child objects must be a list -- so

Plain Text
parent_node.relationships[NodeRelationship.CHILD] = [
  RelatedNodeInfo(
      node_id=child_node.node_id
  )
]
Thanks Logan!

I had one more doubt, I built a custom graph using these TextNodes and then create an index out of them.

However, when I try to query it with a query engine, I don't get anything (I am pretty sure I'm missing a few steps).

The content I want to query is in TextNode.metadata and TextNode,text.

Do you have any example that I can refer to for doing something like this?

It seems like I'll have to define a custom retriever for this. Is that true?
yea by default it won't be following the relationships really πŸ€” What kind of index did you create? Vector? PropertyGraph?
VectorIndex.

I was wondering if it is possible to structure data while pushing nodes into a vector store.

That thinking led me to the path of creating a custom graph.

I wrote a small class to take in a structured json (along with a schema) and generate a graph out of it.

Once I had a graph (i.e. a lot of nodes with parent/child relationships), I decided to experiment with pushing them into an index. So far that hasn't worked out for me.

Planning to explore custom retrievers next. Open to suggestions though!

I also came across the documentation on PropertyGraph, but I decided to continue experimenting with a custom graph for a while longer before trying that out (so that I come out with a better understanding of LlamaIndex)
Add a reply
Sign up and join the conversation on Discord