Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add matching source_node.node_id verification #13109

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions llama-index-core/llama_index/core/node_parser/interface.py
Expand Up @@ -99,11 +99,17 @@ def get_nodes_from_documents(
)

if self.include_prev_next_rel:
if i > 0:
if (
i > 0
and nodes[i - 1].source_node.node_id == node.source_node.node_id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also check if source_node is none or not too actually (I can imagine it being none sometimes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout. Just pushed the change.

):
node.relationships[NodeRelationship.PREVIOUS] = nodes[
i - 1
].as_related_node_info()
if i < len(nodes) - 1:
if (
i < len(nodes) - 1
and nodes[i + 1].source_node.node_id == node.source_node.node_id
):
node.relationships[NodeRelationship.NEXT] = nodes[
i + 1
].as_related_node_info()
Expand Down