Skip to content

Agentic graph

Neo4j implementation of BaseAgenticGraphCapability.

This module provides agentic graph exploration operations for Neo4j — read-only, context-aware methods adapted from GRASP (Graph Retrieval-Augmented Search Pattern).

Neo4jAgenticGraphCapability(retrieve)

Bases: BaseAgenticGraphCapability

Neo4j implementation of :class:BaseAgenticGraphCapability.

Provides read-only, context-aware graph exploration methods for AI agents. Accessed via the :attr:~gllm_datastore.data_store.neo4j.graph.Neo4jGraphCapability.agent property; delegates all query execution to the injected retrieve callable so that driver, database, retry logic, timeout, and result-size limits remain in one place.

Initialize the capability.

Parameters:

Name Type Description Default
retrieve Callable[..., Awaitable[list[dict[str, Any]]]]

Bound :meth:~gllm_datastore.data_store.neo4j.graph.Neo4jGraphCapability.retrieve method. Provides read-only execution with a default timeout=60 s and max_results=100 safety cap that match the original read_only_query contract from :class:~gllm_datastore.graph_data_store.mixins.AgenticGraphToolsMixin.

required

get_neighborhood(node_id=None, relationship_type=None, target_node_id=None, limit=10) async

Get graph patterns matching partial constraints.

Parameters:

Name Type Description Default
node_id str | None

Source node ID. Defaults to None.

None
relationship_type str | None

Relationship type. Defaults to None.

None
target_node_id str | None

Target node ID. Defaults to None.

None
limit int

Maximum patterns to return. Defaults to 10.

10

Returns:

Type Description
list[Triplet]

list[Triplet]: Triplets matching the given constraints.

Raises:

Type Description
ValueError

If none of the three constraints is provided.

search_autocomplete(query, query_pattern, search_var, limit=10) async

Context-sensitive search constrained by a partial query pattern.

Parameters:

Name Type Description Default
query str

Search query string.

required
query_pattern str

Partial Cypher pattern containing search_var as a variable.

required
search_var str

Variable name to search for (e.g., "company").

required
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Node]

list[Node]: Nodes matching the query within the pattern context.

search_constrained(query, position, source_node_id=None, relationship_type=None, target_node_id=None, limit=10) async

Search for items in a specific pattern position under constraints.

Parameters:

Name Type Description Default
query str

Search query string.

required
position SearchPosition

What to search for: SOURCE, RELATIONSHIP, or TARGET.

required
source_node_id str | None

Constraint on source node. Defaults to None.

None
relationship_type str | None

Constraint on relationship type. Defaults to None.

None
target_node_id str | None

Constraint on target node. Defaults to None.

None
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Node] | list[Triplet]

list[Node] | list[Triplet]: Nodes when position is SOURCE or TARGET; triplets when position is RELATIONSHIP.

search_node(query, node_label=None, limit=10) async

Search nodes using case-insensitive substring matching.

Searches across id, name, title, and description properties.

Parameters:

Name Type Description Default
query str

Search query string.

required
node_label str | None

Optional node label to filter results. Defaults to None.

None
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Node]

list[Node]: Matching nodes.

search_rel_of_node(query, node_id, direction=RelationshipDirection.BOTH, limit=10) async

Search for relationships connected to a specific node.

Parameters:

Name Type Description Default
query str

Search query string.

required
node_id str

Node ID to search relationships for.

required
direction RelationshipDirection

Relationship direction. Defaults to :attr:~gllm_datastore.graph_data_store.schema.RelationshipDirection.BOTH.

BOTH
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Triplet]

list[Triplet]: Triplets for relationships connected to the node.

search_relationship(query, node_label=None, limit=10) async

Search for relationship types using substring matching.

Uses a two-step approach: first find distinct matching types, then fetch one representative triplet per type.

Parameters:

Name Type Description Default
query str

Search query string.

required
node_label str | None

Optional node label to filter. Defaults to None.

None
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Triplet]

list[Triplet]: One representative triplet per matching relationship type.

search_target_of_rel(query, relationship_type, source_node_id=None, limit=10) async

Search for target nodes reachable via a relationship type.

Parameters:

Name Type Description Default
query str

Search query string.

required
relationship_type str

Relationship type to traverse.

required
source_node_id str | None

Optional source node. Defaults to None.

None
limit int

Maximum results to return. Defaults to 10.

10

Returns:

Type Description
list[Node]

list[Node]: Target nodes matching the query.