feat: support custom fields in ainsert_custom_kg for entities and relationships#2732
Closed
Br1an67 wants to merge 1 commit intoHKUDS:mainfrom
Closed
feat: support custom fields in ainsert_custom_kg for entities and relationships#2732Br1an67 wants to merge 1 commit intoHKUDS:mainfrom
Br1an67 wants to merge 1 commit intoHKUDS:mainfrom
Conversation
…ationships Pass through extra fields from entity_data and relationship_data that are not in the reserved set into node_data and edge_data, allowing domain-specific metadata to be stored in the knowledge graph. Fixes HKUDS#2488
Contributor
Author
|
Hi — just a gentle bump on this. Happy to make any changes if needed! |
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.
Description
The
ainsert_custom_kgmethod currently only supports a fixed set of fields for entities and relationships. This change passes through extra fields from user-provided data into the knowledge graph storage, enabling domain-specific metadata.Related Issues
Fixes #2488
Changes Made
lightrag/lightrag.py: Modifiedainsert_custom_kgto forward custom fields:entity_data(beyondentity_name,entity_type,description,source_id,file_path) are merged intonode_databefore upserting.relationship_data(beyondsrc_id,tgt_id,description,keywords,weight,source_id,file_path) are merged into both the graphedge_dataand the trackingedge_data.Checklist
Additional Notes
The underlying storage implementations (Neo4j, NetworkX, etc.) already support arbitrary fields — the limitation was only in
ainsert_custom_kgnot passing them through. This is fully backward compatible since existing calls without custom fields are unaffected.