Skip to content

Fix invalid extracted schema #375

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

Merged

Conversation

NathalieCharbel
Copy link
Contributor

Description

When using SchemaFromTextExtractor for automatic schema extraction, the LLM sometimes generates patterns that reference undefined node types or relationship types. This causes Pydantic validation errors in GraphSchema.model_validate(), leading to pipeline crashes.

This PR adds a post processing layer after schema is inferred to filter out invalid patterns before schema validation.

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update
  • Project configuration change

Complexity

Complexity: low

How Has This Been Tested?

  • Unit tests
  • E2E tests
  • Manual tests

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • Unit tests have been updated
  • E2E tests have been updated
  • Examples have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed
  • CHANGELOG.md updated if appropriate

@NathalieCharbel NathalieCharbel requested a review from a team as a code owner July 2, 2025 07:48
@NathalieCharbel NathalieCharbel requested a review from stellasia July 2, 2025 08:34
Copy link
Contributor

@stellasia stellasia left a comment

Choose a reason for hiding this comment

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

Minor comments/questions, but looks great, thanks for working on this!

@NathalieCharbel NathalieCharbel merged commit 522d232 into neo4j:main Jul 2, 2025
8 checks passed
@NathalieCharbel NathalieCharbel deleted the fix-invalid-extracted-schema branch July 2, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants