Skip to content

Conversation

@hamadsuniverse
Copy link
Contributor

Problem

When working with Neptune graphs in LangChain applications, the auto-generated schema lacks meaningful descriptions for node and edge properties. This makes it difficult for LLMs to understand the semantic meaning of properties, leading to suboptimal query generation and reduced accuracy in graph-based RAG applications.

Solution

Add optional property_descriptions parameter to Neptune graph classes that allows users to inject custom descriptions for specific properties in the schema output.

API Design

property_descriptions = {
    ("Person", "name"): "Full name of the person",
    ("Company", "founded"): "Year the company was founded", 
    ("WORKS_FOR", "since"): "Start date of employment"
}

graph = NeptuneGraph(
    host="my-cluster",
    property_descriptions=property_descriptions
)

Usage Patterns

  • Domain-specific graphs: Add business context to technical property names
  • Multi-tenant applications: Provide consistent property semantics across different graph schemas
  • LLM applications: Improve query generation accuracy with meaningful property descriptions

Implementation Details

  • Added property_descriptions parameter to BaseNeptuneGraph, NeptuneGraph, and NeptuneAnalyticsGraph
  • Implemented _inject_property_descriptions() helper method in base class
  • Maintains backward compatibility with optional parameter defaulting to empty dict
  • Follows existing code patterns and minimal design philosophy

Integration Considerations

  • Existing features: No breaking changes, purely additive functionality
  • Performance: Minimal overhead - only processes descriptions when provided
  • Dependencies: No new dependencies introduced
  • Security: No security implications - operates on user-provided metadata only

Note: This addresses a common pain point when using Neptune graphs with LLMs, where property names like emp_dt or org_id lack semantic context needed for accurate query generation.

Add optional property_descriptions parameter to BaseNeptuneGraph, NeptuneGraph,
and NeptuneAnalyticsGraph classes to allow injecting custom descriptions for
node and edge properties in the schema output.
@michaelnchin michaelnchin changed the title Add property descriptions support to Neptune graph classes feat: Add property descriptions support to Neptune graph classes Oct 20, 2025
hamadsuniverse and others added 2 commits October 21, 2025 12:40
Break long lines in BaseNeptuneGraph.__init__, _refresh_schema, and
NeptuneAnalyticsGraph._refresh_schema methods to comply with line length limit.
Copy link
Collaborator

@michaelnchin michaelnchin left a comment

Choose a reason for hiding this comment

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

LGTM - thanks @hamadsuniverse !

@michaelnchin michaelnchin merged commit 52c0bf7 into langchain-ai:main Oct 23, 2025
12 checks passed
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