Skip to content

feat: support custom fields in ainsert_custom_kg for entities and relationships#2732

Closed
Br1an67 wants to merge 1 commit intoHKUDS:mainfrom
Br1an67:fix/issue-2488-custom-kg-fields
Closed

feat: support custom fields in ainsert_custom_kg for entities and relationships#2732
Br1an67 wants to merge 1 commit intoHKUDS:mainfrom
Br1an67:fix/issue-2488-custom-kg-fields

Conversation

@Br1an67
Copy link
Copy Markdown
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Description

The ainsert_custom_kg method 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: Modified ainsert_custom_kg to forward custom fields:
    • Entities: Extra fields in entity_data (beyond entity_name, entity_type, description, source_id, file_path) are merged into node_data before upserting.
    • Relationships: Extra fields in relationship_data (beyond src_id, tgt_id, description, keywords, weight, source_id, file_path) are merged into both the graph edge_data and the tracking edge_data.

Checklist

  • Changes tested locally
  • Code reviewed
  • Documentation updated (if necessary)
  • Unit tests added (if applicable)

Additional Notes

The underlying storage implementations (Neo4j, NetworkX, etc.) already support arbitrary fields — the limitation was only in ainsert_custom_kg not passing them through. This is fully backward compatible since existing calls without custom fields are unaffected.

…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
@Br1an67
Copy link
Copy Markdown
Contributor Author

Br1an67 commented Mar 8, 2026

Hi — just a gentle bump on this. Happy to make any changes if needed!

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.

Feature Request: Support custom fields in ainsert_custom_kg for entities and relationships

2 participants