haive.core.engine.retriever.providers.LlamaIndexGraphRetrieverConfig

LlamaIndex Graph Retriever implementation for the Haive framework.

This module provides a configuration class for the LlamaIndex Graph retriever, which performs graph-based retrieval using knowledge graphs and graph databases like Neo4j, providing semantic relationships and graph traversal capabilities.

The LlamaIndexGraphRetriever works by: 1. Using a graph index (knowledge graph, Neo4j, etc.) as the underlying storage 2. Performing graph traversal queries to find related nodes and relationships 3. Converting graph nodes and edges into retrievable documents 4. Supporting both entity-based and relationship-based retrieval

This retriever is particularly useful when: - Working with knowledge graphs and structured data - Need to understand relationships between entities - Building systems that require graph traversal and exploration - Integrating with Neo4j or other graph databases - Performing semantic retrieval over connected data

The implementation integrates with LangChain Community’s LlamaIndexGraphRetriever while providing a consistent Haive configuration interface with graph database support.

Classes

LlamaIndexGraphRetrieverConfig

Configuration for LlamaIndex Graph retriever in the Haive framework.

Module Contents

class haive.core.engine.retriever.providers.LlamaIndexGraphRetrieverConfig.LlamaIndexGraphRetrieverConfig[source]

Bases: haive.core.common.mixins.secure_config.SecureConfigMixin, haive.core.engine.retriever.retriever.BaseRetrieverConfig

Configuration for LlamaIndex Graph retriever in the Haive framework.

This retriever performs graph-based retrieval using knowledge graphs and graph databases, providing semantic relationships and graph traversal capabilities.

retriever_type

The type of retriever (always LLAMA_INDEX_GRAPH).

Type:

RetrieverType

graph_type

Type of graph backend (‘neo4j’, ‘networkx’, ‘knowledge_graph’).

Type:

str

connection_url

Connection URL for graph database (for Neo4j).

Type:

Optional[str]

database_name

Database name (for Neo4j).

Type:

Optional[str]

api_key

API key for graph services (auto-resolved).

Type:

Optional[SecretStr]

query_type

Type of graph query (‘node’, ‘relationship’, ‘path’, ‘subgraph’).

Type:

str

max_depth

Maximum traversal depth in the graph.

Type:

int

k

Number of top results to return.

Type:

int

Examples

>>> from haive.core.engine.retriever import LlamaIndexGraphRetrieverConfig
>>>
>>> # Create Neo4j graph retriever
>>> config = LlamaIndexGraphRetrieverConfig(
...     name="neo4j_graph_retriever",
...     graph_type="neo4j",
...     connection_url="bolt://localhost:7687",
...     database_name="knowledge",
...     query_type="relationship",
...     max_depth=3,
...     k=10
... )
>>>
>>> # Create knowledge graph retriever
>>> config = LlamaIndexGraphRetrieverConfig(
...     name="knowledge_graph_retriever",
...     graph_type="knowledge_graph",
...     query_type="subgraph",
...     max_depth=2,
...     k=5
... )
>>>
>>> # Instantiate and use the retriever
>>> retriever = config.instantiate()
>>> docs = retriever.get_relevant_documents("artificial intelligence concepts")
get_input_fields()[source]

Return input field definitions for LlamaIndex Graph retriever.

Return type:

dict[str, tuple[type, Any]]

get_output_fields()[source]

Return output field definitions for LlamaIndex Graph retriever.

Return type:

dict[str, tuple[type, Any]]

instantiate()[source]

Create a LlamaIndex Graph retriever from this configuration.

Returns:

Instantiated retriever ready for graph-based retrieval.

Return type:

LlamaIndexGraphRetriever

Raises:
classmethod validate_connection_url(v, info)[source]

Validate connection URL for Neo4j.

classmethod validate_graph_type(v)[source]

Validate graph type.

classmethod validate_query_type(v)[source]

Validate query type.