Declare identity properties, and require descriptions - #347
Merged
Conversation
EntityType carries identity_properties, which is what deduplication compares when two nodes of the same type are candidates for merging. The DSL had no way to say a property is one, so an ontology declared through it could not use the feature at all. A property annotated Annotated[EntityText, Identity] is now listed in the type's identity_properties, in declaration order. Edge types have no identity properties, since only nodes are deduplicated. A missing description is now an error rather than an empty string. Both a type description and a property description go into the extraction prompt as the account of what belongs to the type, and the ontology write path does not reject an empty one, so an undescribed property degraded extraction silently. This is a break for a declaration that left one out, which is worth taking inside the alpha: the Go and TypeScript DSLs reject the same thing, and the error names the type and property so the fix is mechanical. The name in each message is the ontology type name the caller wrote, which is what the API sees, rather than the Python class name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two gaps in the ontology DSL, found while writing the Go and TypeScript equivalents (getzep/zep-go#111, getzep/zep-js#221). All three now behave the same way.
Identity properties
EntityTypecarriesidentity_properties, which deduplication compares when two nodes of the same type are candidates for merging. The DSL had no way to say a property is one, so an ontology declared through it could not use the feature at all.Listed in declaration order. Edge types have none, since only nodes are deduplicated.
Descriptions are now required
A missing description raises
ValueErrornaming the type and property, rather than sending an empty string.Both a type description (the docstring) and a property description go into the extraction prompt as the account of what belongs to the type. An empty one is accepted by the API, so an undescribed property was a silent quality loss rather than a failure — the shape of bug the DSL's existing "is not an ontology property" error already exists to prevent.
This is a break for a declaration that left a description out:
Worth taking inside the alpha: the error names the type and property, so the fix is mechanical, and the Go and TypeScript DSLs reject the same thing.
One other change to match: the name in each message is the ontology type name the caller wrote — the dict key, which is what the API sees — rather than the Python class name.
Tests
14, up from 8. New: the identity annotation, declaration order, a type with none, an edge property never becoming one, and one per rejection — a property with no description, an entity with no docstring, an edge with no docstring.
🤖 Generated with Claude Code