Types

RawSearchResult

class neo4j_graphrag.types.RawSearchResult(*, records, metadata=None)[source]

Represents the raw result returned from the retriever get_search_result method. It needs to be formatted further before being returned as a RetrieverResult.

Parameters:
records

A list of records from neo4j.

Type:

list[neo4j.Record]

metadata

Record-related metadata, such as score.

Type:

dict[str, Any] | None

RetrieverResult

class neo4j_graphrag.types.RetrieverResult(*, items, metadata=None)[source]

Represents a result returned from a retriever.

Parameters:
items

A list of retrieved items.

Type:

list[RetrieverResultItem]

metadata

Context-related metadata such as generated Cypher query in the Text2CypherRetriever.

Type:

dict[str, Any] | None

RetrieverResultItem

class neo4j_graphrag.types.RetrieverResultItem(*, content, metadata=None)[source]

A single record returned from a retriever.

Parameters:
content

The context as will be provided to the LLM

Type:

str

metadata

Any metadata that can be included together with the text, related to that record (e.g. another node property)

Type:

Optional[dict]

LLMResponse

class neo4j_graphrag.llm.types.LLMResponse(*, content)[source]
Parameters:

content (str)

LLMMessage

class neo4j_graphrag.types.LLMMessage[source]

RagResultModel

class neo4j_graphrag.generation.types.RagResultModel(*, answer, retriever_result=None)[source]
Parameters:

DocumentInfo

class neo4j_graphrag.experimental.components.types.DocumentInfo(*, path, metadata=None, uid=<factory>)[source]

A document loaded by a DataLoader.

Parameters:
path

Document path.

Type:

str

metadata

Metadata associated with this document.

Type:

Optional[dict[str, Any]]

uid

Unique identifier for this document.

Type:

str

TextChunk

class neo4j_graphrag.experimental.components.types.TextChunk(*, text, index, metadata=None, uid=<factory>)[source]

A chunk of text split from a document by a text splitter.

Parameters:
text

The raw chunk text.

Type:

str

index

The position of this chunk in the original document.

Type:

int

metadata

Metadata associated with this chunk.

Type:

Optional[dict[str, Any]]

uid

Unique identifier for this chunk.

Type:

str

TextChunks

class neo4j_graphrag.experimental.components.types.TextChunks(*, chunks)[source]

A collection of text chunks returned from a text splitter.

Parameters:

chunks (list[TextChunk])

chunks

A list of text chunks.

Type:

list[TextChunk]

Neo4jNode

class neo4j_graphrag.experimental.components.types.Neo4jNode(*, id, label, properties={}, embedding_properties=None)[source]

Represents a Neo4j node.

Parameters:
id

The ID of the node. This ID is used to refer to the node for relationship creation.

Type:

str

label

The label of the node.

Type:

str

properties

A dictionary of properties attached to the node.

Type:

dict[str, Any]

embedding_properties

A list of embedding properties attached to the node.

Type:

Optional[dict[str, list[float]]]

Neo4jRelationship

class neo4j_graphrag.experimental.components.types.Neo4jRelationship(*, start_node_id, end_node_id, type, properties={}, embedding_properties=None)[source]

Represents a Neo4j relationship.

Parameters:
start_node_id

The ID of the start node.

Type:

str

end_node_id

The ID of the end node.

Type:

str

type

The relationship type.

Type:

str

properties

A dictionary of properties attached to the relationship.

Type:

dict[str, Any]

embedding_properties

A list of embedding properties attached to the relationship.

Type:

Optional[dict[str, list[float]]]

Neo4jGraph

class neo4j_graphrag.experimental.components.types.Neo4jGraph(*, nodes=[], relationships=[])[source]

Represents a Neo4j graph.

Parameters:
nodes

A list of nodes in the graph.

Type:

list[Neo4jNode]

relationships

A list of relationships in the graph.

Type:

list[Neo4jRelationship]

KGWriterModel

class neo4j_graphrag.experimental.components.kg_writer.KGWriterModel(*, status, metadata=None)[source]

Data model for the output of the Knowledge Graph writer.

Parameters:
status

Whether the write operation was successful.

Type:

Literal[“SUCCESS”, “FAILURE”]

PropertyType

class neo4j_graphrag.experimental.components.schema.PropertyType(*, name, type, description='', required=False)[source]

Represents a property on a node or relationship in the graph.

Parameters:
  • name (str)

  • type (Literal['BOOLEAN', 'DATE', 'DURATION', 'FLOAT', 'INTEGER', 'LIST', 'LOCAL_DATETIME', 'LOCAL_TIME', 'POINT', 'STRING', 'ZONED_DATETIME', 'ZONED_TIME'])

  • description (str)

  • required (bool)

NodeType

class neo4j_graphrag.experimental.components.schema.NodeType(*, label, description='', properties=[], additional_properties=<factory>)[source]

Represents a possible node in the graph.

Parameters:

RelationshipType

class neo4j_graphrag.experimental.components.schema.RelationshipType(*, label, description='', properties=[], additional_properties=<factory>)[source]

Represents a possible relationship between nodes in the graph.

Parameters:

GraphSchema

class neo4j_graphrag.experimental.components.schema.GraphSchema(*, node_types, relationship_types=(), patterns=(), additional_node_types=<factory>, additional_relationship_types=<factory>, additional_patterns=<factory>)[source]

This model represents the expected node and relationship types in the graph.

It is used both for guiding the LLM in the entity and relation extraction component, and for cleaning the extracted graph in a post-processing step.

Warning

This model is immutable.

Parameters:

LexicalGraphConfig

class neo4j_graphrag.experimental.components.types.LexicalGraphConfig(*, id_prefix='', document_node_label='Document', chunk_node_label='Chunk', chunk_to_document_relationship_type='FROM_DOCUMENT', next_chunk_relationship_type='NEXT_CHUNK', node_to_chunk_relationship_type='FROM_CHUNK', chunk_id_property='id', chunk_index_property='index', chunk_text_property='text', chunk_embedding_property='embedding')[source]

Configure all labels and property names in the lexical graph.

Parameters:
  • id_prefix (str)

  • document_node_label (str)

  • chunk_node_label (str)

  • chunk_to_document_relationship_type (str)

  • next_chunk_relationship_type (str)

  • node_to_chunk_relationship_type (str)

  • chunk_id_property (str)

  • chunk_index_property (str)

  • chunk_text_property (str)

  • chunk_embedding_property (str)

Neo4jDriverType

class neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverType(root=PydanticUndefined)[source]

A model to wrap neo4j.Driver and Neo4jDriverConfig objects.

The parse method always returns a neo4j.Driver.

Parameters:

root (Driver | Neo4jDriverConfig)

Neo4jDriverConfig

class neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverConfig(*, class_=None, params_={})[source]
Parameters:

LLMType

class neo4j_graphrag.experimental.pipeline.config.object_config.LLMType(root=PydanticUndefined)[source]

A model to wrap LLMInterface and LLMConfig objects.

The parse method always returns an object inheriting from LLMInterface.

Parameters:

root (LLMInterface | LLMConfig)

LLMConfig

class neo4j_graphrag.experimental.pipeline.config.object_config.LLMConfig(*, class_=None, params_={})[source]

Configuration for any LLMInterface object.

By default, will try to import from neo4j_graphrag.llm.

Parameters:

EmbedderType

class neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderType(root=PydanticUndefined)[source]

A model to wrap Embedder and EmbedderConfig objects.

The parse method always returns an object inheriting from Embedder.

Parameters:

root (Embedder | EmbedderConfig)

EmbedderConfig

class neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderConfig(*, class_=None, params_={})[source]

Configuration for any Embedder object.

By default, will try to import from neo4j_graphrag.embeddings.

Parameters:

ComponentType

class neo4j_graphrag.experimental.pipeline.config.object_config.ComponentType(root=PydanticUndefined)[source]
Parameters:

root (Component | ComponentConfig)

ComponentConfig

class neo4j_graphrag.experimental.pipeline.config.object_config.ComponentConfig(*, class_=None, params_={}, run_params_={})[source]

A config model for all components.

In addition to the object config, components can have pre-defined parameters that will be passed to the run method, ie run_params_.

Parameters:

ParamFromEnvConfig

class neo4j_graphrag.experimental.pipeline.config.param_resolver.ParamFromEnvConfig(*, resolver_=ParamResolverEnum.ENV, var_)[source]
Parameters:
  • resolver_ (Literal[ParamResolverEnum.ENV])

  • var_ (str)

EventType

enum neo4j_graphrag.experimental.pipeline.notification.EventType(value)[source]

Valid values are as follows:

PIPELINE_STARTED = <EventType.PIPELINE_STARTED: 'PIPELINE_STARTED'>
TASK_STARTED = <EventType.TASK_STARTED: 'TASK_STARTED'>
TASK_PROGRESS = <EventType.TASK_PROGRESS: 'TASK_PROGRESS'>
TASK_FINISHED = <EventType.TASK_FINISHED: 'TASK_FINISHED'>
PIPELINE_FINISHED = <EventType.PIPELINE_FINISHED: 'PIPELINE_FINISHED'>
PIPELINE_FAILED = <EventType.PIPELINE_FAILED: 'PIPELINE_FAILED'>

PipelineEvent

class neo4j_graphrag.experimental.pipeline.notification.PipelineEvent(*, event_type, run_id, timestamp=<factory>, message=None, payload=None)[source]
Parameters:

TaskEvent

class neo4j_graphrag.experimental.pipeline.notification.TaskEvent(*, event_type, run_id, timestamp=<factory>, message=None, payload=None, task_name)[source]
Parameters:

EventCallbackProtocol

class neo4j_graphrag.experimental.pipeline.notification.EventCallbackProtocol(*args, **kwargs)[source]

This protocol is used to send events about pipeline progress from the pipeline itself. It will receive either PipelineEvent or TaskEvent depending on the event type.

__call__(event)[source]

Call self as a function.

Parameters:

event (Event)

Return type:

Awaitable[None]

TaskProgressCallbackProtocol

class neo4j_graphrag.experimental.pipeline.types.context.TaskProgressNotifierProtocol(*args, **kwargs)[source]

This protocol is used to send events from the component to the Pipeline callback protocol. The event sent to the callback will be of type TaskEvent, with event_type=TASK_PROGRESS.

__call__(message, data)[source]

Call self as a function.

Parameters:
Return type:

Awaitable[None]

RunContext

class neo4j_graphrag.experimental.pipeline.types.context.RunContext(*, run_id, task_name, notifier=None)[source]

Context passed to the component

Parameters: