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

Conversation

alineberry
Copy link
Contributor

@alineberry alineberry commented Apr 25, 2024

Description

Update NodeParser.get_nodes_from_documents to verify that previous and next nodes share the same source node as the current node before defining prev_node and next_node relationships.

See issue linked below for more context.

Fixes # (issue)
#13095

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

This was a very minor change and I didn't see a test that specifically covered the method I modified. Existing tests passed.

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

@alineberry alineberry marked this pull request as ready for review April 25, 2024 17:27
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 25, 2024
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.

@alineberry
Copy link
Contributor Author

Following up :)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 1, 2024
@logan-markewich logan-markewich enabled auto-merge (squash) May 1, 2024 05:26
@logan-markewich logan-markewich merged commit 8bf72cc into run-llama:main May 1, 2024
8 checks passed
JuHyung-Son pushed a commit to UpstageAI/llama_index that referenced this pull request May 1, 2024
* add matching source_node.node_id verification

* check that source_node exists

---------

Co-authored-by: Adam Lineberry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants