참고소스 수정본

This commit is contained in:
LASTA_DEV01\lasta
2026-05-12 19:40:31 +09:00
parent 0f34a451fc
commit 2e9204243d
8708 changed files with 3259488 additions and 869 deletions

View File

@@ -0,0 +1,7 @@
{%- extends "layout.html" %}
{% set title = _('Tree') %}
{% block body %}
<h1>{{ _('Tree') }}</h1>
{{ toctree(includehidden=True, collapse=False, maxdepth=-1) }}
{% endblock %}

View File

@@ -0,0 +1,18 @@
<div id="indexlinkbox">
<h3 id="indexlinklabel">{{ _('Index') }}</h3>
<div class="indexlinkwrapper nav-menu">
<ul>
<li class="toctree-l1">
<a href="{{ pathto('genindex')|e }}" class="indexlink genindex">
{{ _('Alphabetical') }}
</a>
</li>
<li class="toctree-l1">
<a href="{{ pathto('gentree')|e }}" class="indexlink gentree">
{{ _('Tree') }}
</a>
</li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,733 @@
.. _api-documentation:
API Documentation
#################
.. _components-section:
**********
Components
**********
Component
=========
.. autoclass:: neo4j_graphrag.experimental.pipeline.component.Component
:members: run, run_with_context
DataLoader
==========
.. autoclass:: neo4j_graphrag.experimental.components.data_loader.DataLoader
:members: run, get_document_metadata
PdfLoader
=========
.. autoclass:: neo4j_graphrag.experimental.components.data_loader.PdfLoader
:members: run, load_file
MarkdownLoader
==============
.. autoclass:: neo4j_graphrag.experimental.components.data_loader.MarkdownLoader
:members: run, load_file
TextSplitter
============
.. autoclass:: neo4j_graphrag.experimental.components.text_splitters.base.TextSplitter
:members: run
FixedSizeSplitter
=================
.. autoclass:: neo4j_graphrag.experimental.components.text_splitters.fixed_size_splitter.FixedSizeSplitter
:members: run
LangChainTextSplitterAdapter
============================
.. autoclass:: neo4j_graphrag.experimental.components.text_splitters.langchain.LangChainTextSplitterAdapter
:members: run
LlamaIndexTextSplitterAdapter
=============================
.. autoclass:: neo4j_graphrag.experimental.components.text_splitters.llamaindex.LlamaIndexTextSplitterAdapter
:members: run
TextChunkEmbedder
=================
.. autoclass:: neo4j_graphrag.experimental.components.embedder.TextChunkEmbedder
:members: run
LexicalGraphBuilder
===================
.. autoclass:: neo4j_graphrag.experimental.components.lexical_graph.LexicalGraphBuilder
:members:
:exclude-members: component_inputs, component_outputs
Neo4jChunkReader
================
.. autoclass:: neo4j_graphrag.experimental.components.neo4j_reader.Neo4jChunkReader
:members:
:exclude-members: component_inputs, component_outputs
SchemaBuilder
=============
.. autoclass:: neo4j_graphrag.experimental.components.schema.SchemaBuilder
:members: run
SchemaFromTextExtractor
-----------------------
.. autoclass:: neo4j_graphrag.experimental.components.schema.SchemaFromTextExtractor
:members: run
schema_visualization
--------------------
.. autofunction:: neo4j_graphrag.experimental.utils.schema.schema_visualization
EntityRelationExtractor
=======================
.. autoclass:: neo4j_graphrag.experimental.components.entity_relation_extractor.EntityRelationExtractor
:members:
:exclude-members: component_inputs, component_outputs
LLMEntityRelationExtractor
==========================
.. autoclass:: neo4j_graphrag.experimental.components.entity_relation_extractor.LLMEntityRelationExtractor
:members: run
KGWriter
========
.. autoclass:: neo4j_graphrag.experimental.components.kg_writer.KGWriter
:members: run
Neo4jWriter
===========
.. autoclass:: neo4j_graphrag.experimental.components.kg_writer.Neo4jWriter
:members: run
SinglePropertyExactMatchResolver
================================
.. autoclass:: neo4j_graphrag.experimental.components.resolver.SinglePropertyExactMatchResolver
:members: run
SpaCySemanticMatchResolver
==========================
.. autoclass:: neo4j_graphrag.experimental.components.resolver.SpaCySemanticMatchResolver
:members: run
FuzzyMatchResolver
==================
.. autoclass:: neo4j_graphrag.experimental.components.resolver.FuzzyMatchResolver
:members: run
.. _pipeline-section:
*********
Pipelines
*********
Pipeline
========
.. autoclass:: neo4j_graphrag.experimental.pipeline.Pipeline
:members: run, add_component, connect, draw
SimpleKGPipeline
================
.. autoclass:: neo4j_graphrag.experimental.pipeline.kg_builder.SimpleKGPipeline
:members: run_async
************
Config files
************
SimpleKGPipelineConfig
======================
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.template_pipeline.simple_kg_builder.SimpleKGPipelineConfig
PipelineRunner
==============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.runner.PipelineRunner
.. _retrievers-section:
**********
Retrievers
**********
RetrieverInterface
==================
.. autoclass:: neo4j_graphrag.retrievers.base.Retriever
:members:
VectorRetriever
===============
.. autoclass:: neo4j_graphrag.retrievers.VectorRetriever
:members: search
VectorCypherRetriever
=====================
.. autoclass:: neo4j_graphrag.retrievers.VectorCypherRetriever
:members: search
HybridRetriever
===============
.. autoclass:: neo4j_graphrag.retrievers.HybridRetriever
:members: search
HybridCypherRetriever
=====================
.. autoclass:: neo4j_graphrag.retrievers.HybridCypherRetriever
:members: search
Text2CypherRetriever
=====================
.. autoclass:: neo4j_graphrag.retrievers.Text2CypherRetriever
:members: search
ToolsRetriever
==============
.. autoclass:: neo4j_graphrag.retrievers.ToolsRetriever
:members: search
*******************
External Retrievers
*******************
This section includes retrievers that integrate with databases external to Neo4j.
WeaviateNeo4jRetriever
======================
.. autoclass:: neo4j_graphrag.retrievers.external.weaviate.weaviate.WeaviateNeo4jRetriever
:members: search
PineconeNeo4jRetriever
======================
.. autoclass:: neo4j_graphrag.retrievers.external.pinecone.pinecone.PineconeNeo4jRetriever
:members: search
QdrantNeo4jRetriever
====================
.. autoclass:: neo4j_graphrag.retrievers.external.qdrant.qdrant.QdrantNeo4jRetriever
:members: search
********
Embedder
********
.. autoclass:: neo4j_graphrag.embeddings.base.Embedder
:members:
SentenceTransformerEmbeddings
=============================
.. autoclass:: neo4j_graphrag.embeddings.sentence_transformers.SentenceTransformerEmbeddings
:members:
OpenAIEmbeddings
================
.. autoclass:: neo4j_graphrag.embeddings.openai.OpenAIEmbeddings
:members:
AzureOpenAIEmbeddings
=====================
.. autoclass:: neo4j_graphrag.embeddings.openai.AzureOpenAIEmbeddings
:members:
OllamaEmbeddings
================
.. autoclass:: neo4j_graphrag.embeddings.ollama.OllamaEmbeddings
:members:
VertexAIEmbeddings
==================
.. autoclass:: neo4j_graphrag.embeddings.vertexai.VertexAIEmbeddings
:members:
MistralAIEmbeddings
===================
.. autoclass:: neo4j_graphrag.embeddings.mistral.MistralAIEmbeddings
:members:
BedrockEmbeddings
=================
.. autoclass:: neo4j_graphrag.embeddings.bedrock.BedrockEmbeddings
:members:
CohereEmbeddings
================
.. autoclass:: neo4j_graphrag.embeddings.cohere.CohereEmbeddings
:members:
**********
Generation
**********
LLM
===
LLMInterface
------------
.. autoclass:: neo4j_graphrag.llm.LLMInterface
:members:
LLMBase
-------
.. autoclass:: neo4j_graphrag.llm.LLMBase
:members:
OpenAILLM
---------
.. autoclass:: neo4j_graphrag.llm.openai_llm.OpenAILLM
:members:
:undoc-members: get_messages, client_class, async_client_class
AzureOpenAILLM
--------------
.. autoclass:: neo4j_graphrag.llm.openai_llm.AzureOpenAILLM
:members:
:undoc-members: get_messages, client_class, async_client_class
OllamaLLM
---------
.. autoclass:: neo4j_graphrag.llm.ollama_llm.OllamaLLM
:members:
VertexAILLM
-----------
.. autoclass:: neo4j_graphrag.llm.vertexai_llm.VertexAILLM
:members:
AnthropicLLM
------------
.. autoclass:: neo4j_graphrag.llm.anthropic_llm.AnthropicLLM
:members:
BedrockLLM
----------
.. autoclass:: neo4j_graphrag.llm.bedrock_llm.BedrockLLM
:members:
CohereLLM
---------
.. autoclass:: neo4j_graphrag.llm.cohere_llm.CohereLLM
:members:
MistralAILLM
------------
.. autoclass:: neo4j_graphrag.llm.mistralai_llm.MistralAILLM
:members:
Rate Limiting
=============
RateLimitHandler
----------------
.. autoclass:: neo4j_graphrag.utils.rate_limit.RateLimitHandler
:members:
RetryRateLimitHandler
---------------------
.. autoclass:: neo4j_graphrag.utils.rate_limit.RetryRateLimitHandler
:members:
NoOpRateLimitHandler
--------------------
.. autoclass:: neo4j_graphrag.utils.rate_limit.NoOpRateLimitHandler
:members:
PromptTemplate
==============
.. autoclass:: neo4j_graphrag.generation.prompts.PromptTemplate
:members:
RagTemplate
-----------
.. autoclass:: neo4j_graphrag.generation.prompts.RagTemplate
:members:
:exclude-members: format
ERExtractionTemplate
--------------------
.. autoclass:: neo4j_graphrag.generation.prompts.ERExtractionTemplate
:members:
:exclude-members: format
SchemaExtractionTemplate
------------------------
.. autoclass:: neo4j_graphrag.generation.prompts.SchemaExtractionTemplate
:members:
:exclude-members: format
Text2CypherTemplate
--------------------
.. autoclass:: neo4j_graphrag.generation.prompts.Text2CypherTemplate
:members:
:exclude-members: format
****
RAG
****
GraphRAG
========
.. autoclass:: neo4j_graphrag.generation.graphrag.GraphRAG
:members:
.. _database-interaction-section:
********************
Database Interaction
********************
.. _create-vector-index:
.. autofunction:: neo4j_graphrag.indexes.create_vector_index
.. _create-fulltext-index:
.. autofunction:: neo4j_graphrag.indexes.create_fulltext_index
.. autofunction:: neo4j_graphrag.indexes.drop_index_if_exists
.. autofunction:: neo4j_graphrag.indexes.upsert_vectors
.. autofunction:: neo4j_graphrag.indexes.upsert_vector
.. autofunction:: neo4j_graphrag.indexes.upsert_vector_on_relationship
.. autofunction:: neo4j_graphrag.indexes.async_upsert_vector
.. autofunction:: neo4j_graphrag.indexes.async_upsert_vector_on_relationship
.. autofunction:: neo4j_graphrag.indexes.retrieve_vector_index_info
.. autofunction:: neo4j_graphrag.indexes.retrieve_fulltext_index_info
.. autofunction:: neo4j_graphrag.schema.get_structured_schema
.. autofunction:: neo4j_graphrag.schema.get_schema
.. autofunction:: neo4j_graphrag.schema.format_schema
***************
Message History
***************
.. autoclass:: neo4j_graphrag.message_history.InMemoryMessageHistory
.. autoclass:: neo4j_graphrag.message_history.Neo4jMessageHistory
******
Errors
******
* :class:`neo4j_graphrag.exceptions.Neo4jGraphRagError`
* :class:`neo4j_graphrag.exceptions.RetrieverInitializationError`
* :class:`neo4j_graphrag.exceptions.EmbeddingsGenerationError`
* :class:`neo4j_graphrag.exceptions.SearchValidationError`
* :class:`neo4j_graphrag.exceptions.FilterValidationError`
* :class:`neo4j_graphrag.exceptions.EmbeddingRequiredError`
* :class:`neo4j_graphrag.exceptions.InvalidRetrieverResultError`
* :class:`neo4j_graphrag.exceptions.Neo4jIndexError`
* :class:`neo4j_graphrag.exceptions.Neo4jVersionError`
* :class:`neo4j_graphrag.exceptions.Text2CypherRetrievalError`
* :class:`neo4j_graphrag.exceptions.SchemaFetchError`
* :class:`neo4j_graphrag.exceptions.RagInitializationError`
* :class:`neo4j_graphrag.exceptions.PromptMissingInputError`
* :class:`neo4j_graphrag.exceptions.LLMGenerationError`
* :class:`neo4j_graphrag.exceptions.RateLimitError`
* :class:`neo4j_graphrag.exceptions.SchemaValidationError`
* :class:`neo4j_graphrag.exceptions.PdfLoaderError`
* :class:`neo4j_graphrag.exceptions.PromptMissingPlaceholderError`
* :class:`neo4j_graphrag.exceptions.InvalidHybridSearchRankerError`
* :class:`neo4j_graphrag.exceptions.SearchQueryParseError`
* :class:`neo4j_graphrag.experimental.pipeline.exceptions.PipelineDefinitionError`
* :class:`neo4j_graphrag.experimental.pipeline.exceptions.PipelineMissingDependencyError`
* :class:`neo4j_graphrag.experimental.pipeline.exceptions.PipelineStatusUpdateError`
* :class:`neo4j_graphrag.experimental.pipeline.exceptions.InvalidJSONError`
Neo4jGraphRagError
==================
.. autoclass:: neo4j_graphrag.exceptions.Neo4jGraphRagError
:show-inheritance:
RetrieverInitializationError
============================
.. autoclass:: neo4j_graphrag.exceptions.RetrieverInitializationError
:show-inheritance:
SearchValidationError
=====================
.. autoclass:: neo4j_graphrag.exceptions.SearchValidationError
:show-inheritance:
FilterValidationError
=====================
.. autoclass:: neo4j_graphrag.exceptions.FilterValidationError
:show-inheritance:
EmbeddingsGenerationError
=========================
.. autoclass:: neo4j_graphrag.exceptions.EmbeddingsGenerationError
:show-inheritance:
EmbeddingRequiredError
======================
.. autoclass:: neo4j_graphrag.exceptions.EmbeddingRequiredError
:show-inheritance:
InvalidRetrieverResultError
===========================
.. autoclass:: neo4j_graphrag.exceptions.InvalidRetrieverResultError
:show-inheritance:
Neo4jIndexError
===============
.. autoclass:: neo4j_graphrag.exceptions.Neo4jIndexError
:show-inheritance:
Neo4jInsertionError
===================
.. autoclass:: neo4j_graphrag.exceptions.Neo4jInsertionError
:show-inheritance:
Neo4jVersionError
=================
.. autoclass:: neo4j_graphrag.exceptions.Neo4jVersionError
:show-inheritance:
Text2CypherRetrievalError
=========================
.. autoclass:: neo4j_graphrag.exceptions.Text2CypherRetrievalError
:show-inheritance:
SchemaFetchError
================
.. autoclass:: neo4j_graphrag.exceptions.SchemaFetchError
:show-inheritance:
RagInitializationError
======================
.. autoclass:: neo4j_graphrag.exceptions.RagInitializationError
:show-inheritance:
PromptMissingInputError
=======================
.. autoclass:: neo4j_graphrag.exceptions.PromptMissingInputError
:show-inheritance:
LLMGenerationError
==================
.. autoclass:: neo4j_graphrag.exceptions.LLMGenerationError
:show-inheritance:
RateLimitError
==============
.. autoclass:: neo4j_graphrag.exceptions.RateLimitError
:show-inheritance:
SchemaValidationError
=====================
.. autoclass:: neo4j_graphrag.exceptions.SchemaValidationError
:show-inheritance:
PdfLoaderError
==============
.. autoclass:: neo4j_graphrag.exceptions.PdfLoaderError
:show-inheritance:
PromptMissingPlaceholderError
=============================
.. autoclass:: neo4j_graphrag.exceptions.PromptMissingPlaceholderError
:show-inheritance:
InvalidHybridSearchRankerError
==============================
.. autoclass:: neo4j_graphrag.exceptions.InvalidHybridSearchRankerError
:show-inheritance:
SearchQueryParseError
=====================
.. autoclass:: neo4j_graphrag.exceptions.SearchQueryParseError
:show-inheritance:
PipelineDefinitionError
=======================
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.PipelineDefinitionError
:show-inheritance:
PipelineMissingDependencyError
==============================
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.PipelineMissingDependencyError
:show-inheritance:
PipelineStatusUpdateError
=========================
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.PipelineStatusUpdateError
:show-inheritance:
InvalidJSONError
================
.. autoclass:: neo4j_graphrag.experimental.pipeline.exceptions.InvalidJSONError
:show-inheritance:

View File

@@ -0,0 +1,117 @@
# Copyright (c) "Neo4j"
# Neo4j Sweden AB [https://neo4j.com]
# #
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# #
# https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import typing
# Add the root of the project to the path so that Sphinx can find the Python sources
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "src"))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "neo4j-graphrag-python"
copyright = "2024, Neo4j, Inc."
author = "Neo4j, Inc."
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.ifconfig",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.autosectionlabel",
"enum_tools.autoenum",
]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "neo4j"
html_theme_path = ["themes"]
# 01-nav.js is a copy of a js file of the same name that is included in the
# docs-ui bundle
def setup(app):
app.add_js_file("https://neo4j.com/docs/assets/js/site.js", loading_method="defer")
app.add_js_file("js/12-fragment-jumper.js", loading_method="defer")
# Additional templates that should be rendered to pages, maps page names to
# template names.
html_additional_pages = {"gentree": "gentree.html"}
# The name of the Pygments (syntax highlighting) style to use.
# pygments_style = "sphinx"
pygments_style = "friendly"
# Don't include type hints in function signatures
autodoc_typehints = "description"
autodoc_type_aliases = {
# The code-base uses `import typing_extensions as te`.
# Re-write these to use `typing` instead, as Sphinx always resolves against
# the latest version of the `typing` module.
# This is a work-around to make Sphinx resolve type hints correctly, even
# though we're using `from __future__ import annotations`.
"te": typing,
# Type alias that's only defined and imported if `typing.TYPE_CHECKING`
# is `True`.
"_TAuth": "typing.tuple[typing.Any, typing.Any] | Auth | None",
}
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"sidebar_includehidden": True,
"sidebar_collapse": True,
}
autodoc_default_options = {
"member-order": "bysource",
# 'special-members': '__init__',
"undoc-members": True,
"exclude-members": "__weakref__",
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,336 @@
.. neo4j-graphrag-python documentation master file, created by
sphinx-quickstart on Tue Apr 9 16:36:43 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
GraphRAG for Python
===================
This package contains the official Neo4j GraphRAG features for Python.
The purpose of this package is to provide a first party package to developers,
where Neo4j can guarantee long term commitment and maintenance as well as being
fast to ship new features and high performing patterns and methods.
⚠️ This package is a renamed continuation of `neo4j-genai`.
The package `neo4j-genai` is deprecated and will no longer be maintained.
We encourage all users to migrate to this new package to continue receiving updates and support.
Neo4j versions supported:
* Neo4j >=5.18.1
* Neo4j Aura >=5.18.0
* Neo4j 2026.01+ (enables SEARCH clause with in-index filtering)
Python versions supported:
* Python 3.14
* Python 3.13
* Python 3.12
* Python 3.11
* Python 3.10
******
Topics
******
+ :ref:`user-guide-rag`
+ :ref:`user-guide-kg-builder`
+ :ref:`user-guide-pipeline`
+ :ref:`api-documentation`
+ :ref:`types-documentation`
.. toctree::
:maxdepth: 3
:caption: Contents:
:hidden:
Introduction <self>
user_guide_rag.rst
user_guide_kg_builder.rst
user_guide_pipeline.rst
api.rst
types.rst
Usage
=====
************
Installation
************
This package requires Python (>=3.10).
To install the latest stable version, use:
.. code:: bash
pip install neo4j-graphrag
.. note::
It is always recommended to install python packages for user space in a virtual environment.
*********************
Optional Dependencies
*********************
Extra dependencies can be installed with:
.. code:: bash
pip install "neo4j-graphrag[openai]"
List of extra dependencies:
- LLM providers (at least one is required for RAG and KG Builder Pipeline):
- **ollama**: LLMs from Ollama
- **openai**: LLMs from OpenAI (including AzureOpenAI)
- **google**: LLMs from Vertex AI
- **cohere**: LLMs from Cohere
- **anthropic**: LLMs from Anthropic
- **mistralai**: LLMs from MistralAI
- **sentence-transformers** : to use embeddings from the `sentence-transformers` Python package
- Vector database (to use :ref:`External Retrievers`):
- **weaviate**: store vectors in Weaviate
- **pinecone**: store vectors in Pinecone
- **qdrant**: store vectors in Qdrant
- **experimental**: experimental features mainly from the Knowledge Graph creation pipelines.
- **nlp**: installs spaCy for nlp pipelines, used by `SpaCySemanticMatchResolver` component from the Knowledge Graph creation pipelines.
- **fuzzy-matching**: installs **rapidfuzz** to fuzzy matching using string similarity, used by `FuzzyMatchResolver` component from the Knowledge Graph creation pipelines.
.. note::
The **`nlp`** extra (spaCy) is currently **not supported on Python 3.14** due to an upstream spaCy import-time issue (see `spaCy #13895 <https://github.com/explosion/spaCy/issues/13895>`_). Use Python **3.13 or earlier** for spaCy-based features until that is resolved upstream.
********
Examples
********
~~~~~~~~~~~~~~~~~~~~~~~
Creating a vector index
~~~~~~~~~~~~~~~~~~~~~~~
When creating a vector index, make sure you match the number of dimensions in the index with the number of dimensions the embeddings have.
See :ref:`the API documentation<create-vector-index>` for more details.
.. code:: python
from neo4j import GraphDatabase
from neo4j_graphrag.indexes import create_vector_index
URI = "neo4j://localhost:7687"
AUTH = ("neo4j", "password")
INDEX_NAME = "vector-index-name"
# Connect to Neo4j database
driver = GraphDatabase.driver(URI, auth=AUTH)
# Creating the index
create_vector_index(
driver,
INDEX_NAME,
label="Document",
embedding_property="vectorProperty",
dimensions=1536,
similarity_fn="euclidean",
)
.. note::
Assumed Neo4j is running
On Neo4j 2026.01+, you can also specify ``filterable_properties`` to enable in-index
filtering with the ``SEARCH`` clause. See :ref:`filterable-index-creation` for details.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Populating the Neo4j Vector Index
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that the below example is not the only way you can upsert data into your Neo4j database. For example, you could also leverage `the Neo4j Python driver <https://github.com/neo4j/neo4j-python-driver>`_.
.. code:: python
from neo4j import GraphDatabase
from neo4j_graphrag.indexes import upsert_vectors
from neo4j_graphrag.types import EntityType
URI = "neo4j://localhost:7687"
AUTH = ("neo4j", "password")
# Connect to Neo4j database
driver = GraphDatabase.driver(URI, auth=AUTH)
# Upsert the vector
vector = ...
upsert_vectors(
driver,
ids=["1234"],
embedding_property="vectorProperty",
embeddings=[vector],
entity_type=EntityType.NODE,
)
.. note::
Assumed Neo4j is running with a defined vector index
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Performing a similarity search
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While the library has more retrievers than shown here, the following examples should be able to get you started.
.. code:: python
from neo4j import GraphDatabase
from neo4j_graphrag.embeddings.openai import OpenAIEmbeddings
from neo4j_graphrag.retrievers import VectorRetriever
URI = "neo4j://localhost:7687"
AUTH = ("neo4j", "password")
INDEX_NAME = "vector-index-name"
# Connect to Neo4j database
driver = GraphDatabase.driver(URI, auth=AUTH)
# Create Embedder object
# Note: An OPENAI_API_KEY environment variable is required here
embedder = OpenAIEmbeddings(model="text-embedding-3-large")
# Initialize the retriever
retriever = VectorRetriever(driver, INDEX_NAME, embedder)
# Run the similarity search
query_text = "How do I do similarity search in Neo4j?"
response = retriever.search(query_text=query_text, top_k=5)
.. note::
Assumed Neo4j is running with populated vector index in place.
***********
Limitations
***********
The query over the vector index is an *approximate* nearest neighbor search and may not give exact results. `See this reference for more details <https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes/#limitations-and-issues>`_.
Development
===========
********************
Install dependencies
********************
.. code:: bash
uv sync --all-extras
***************
Getting started
***************
~~~~~~
Issues
~~~~~~
If you have a bug to report or feature to request, first
`search to see if an issue already exists <https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments>`_.
If a related issue doesn't exist, please raise a new issue using the relevant
`issue form <https://github.com/neo4j/neo4j-graphrag-python/issues/new/choose>`_.
If you're a Neo4j Enterprise customer, you can also reach out to `Customer Support <http://support.neo4j.com/>`_.
If you don't have a bug to report or feature request, but you need a hand with
the library; community support is available via `Neo4j Online Community <https://community.neo4j.com/>`_
and/or `Discord <https://discord.gg/neo4j>`_.
~~~~~~~~~~~~
Make changes
~~~~~~~~~~~~
1. Fork the repository.
2. Install Python and uv.
3. Create a working branch from `main` and start with your changes!
~~~~~~~~~~~~
Pull request
~~~~~~~~~~~~
When you're finished with your changes, create a pull request, also known as a PR.
- Ensure that you have `signed the CLA <https://neo4j.com/developer/contributing-code/#sign-cla>`_.
- Ensure that the base of your PR is set to `main`.
- Don't forget to `link your PR to an issue <https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue>`_
if you are solving one.
- Enable the checkbox to `allow maintainer edits <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork>`_
so that maintainers can make any necessary tweaks and update your branch for merge.
- Reviewers may ask for changes to be made before a PR can be merged, either using
`suggested changes <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request>`_
or normal pull request comments. You can apply suggested changes directly through
the UI, and any other changes can be made in your fork and committed to the PR branch.
- As you update your PR and apply changes, mark each conversation as `resolved <https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations>`_.
*********
Run tests
*********
Run the tests using uv.
.. code:: bash
uv run pytest
~~~~~~~~~~
Unit tests
~~~~~~~~~~
This should run out of the box once the dependencies are installed.
.. code:: bash
uv run pytest tests/unit
~~~~~~~~~
E2E tests
~~~~~~~~~
To run e2e tests you'd need to have some services running locally:
- neo4j
- weaviate
- weaviate-text2vec-transformers
The easiest way to get it up and running is via Docker compose:
.. code:: bash
docker compose -f tests/e2e/docker-compose.yml up
.. note::
If you suspect something in the databases are cached, run `docker compose -f tests/e2e/docker-compose.yml down` to remove them completely
Once the services are running, execute the following command to run the e2e tests.
.. code:: bash
uv run pytest tests/e2e
*******************
Further information
*******************
- `The official Neo4j Python driver <https://github.com/neo4j/neo4j-python-driver>`_
- `Neo4j GenAI integrations <https://neo4j.com/docs/cypher-manual/current/genai-integrations/>`_

View File

@@ -0,0 +1,43 @@
<footer class="footer">
<div class="wrapper">
<div class="column">
<div class="logo-footer"></div>
<p>© <span id="footer-copyright-year">{{year}}</span> Neo4j, Inc.<br>
<a href="https://neo4j.com/terms/">Terms</a> | <a href="https://neo4j.com/privacy-policy/">Privacy </a> | <a href="https://neo4j.com/sitemap/">Sitemap</a></p>
<p>Neo4j<sup>®</sup>, Neo Technology<sup>®</sup>, Cypher<sup>®</sup>, Neo4j<sup>®</sup> Bloom<sup></sup> and
Neo4j<sup>®</sup> Aura<sup></sup> are registered trademarks
of Neo4j, Inc. All other marks are owned by their respective companies.</p>
</div>
<div class="column">
<h2><a href="https://neo4j.com/contact-us/?ref=footer">Contact Us →</a></h2>
<p>US: 1-855-636-4532<br>
Sweden +46 171 480 113<br>
UK: +44 20 3868 3223<br>
France: +33 (0) 1 88 46 13 20<br>
<!--Germany: +49 (0)89 26204 6300</p>-->
</p>
</div>
<div class="column links">
<h2>Learn</h2>
<ul>
<li><i class="fa fa-wrench" aria-hidden="true"></i> <a rel="noopener" href="https://neo4j.com/sandbox/?ref=developer-footer">Sandbox</a></li>
<li><i class="fa fa-comments-o" aria-hidden="true"></i> <a rel="noopener" href="https://community.neo4j.com?ref=developer-footer" target="_blank">Neo4j Community Site</a></li>
<li><i class="fa fa-book" aria-hidden="true"></i> <a rel="noopener" href="https://medium.com/neo4j" target="_blank">Neo4j Developer Blog</a></li>
<li><i class="fa fa-youtube" aria-hidden="true"></i> <a rel="noopener" href="https://www.youtube.com/neo4j" target="_blank">Neo4j Videos</a></li>
<li><i class="fa fa-graduation-cap" aria-hidden="true"></i> <a rel="noopener" href="https://neo4j.com/graphacademy/?ref=developer-footer">GraphAcademy</a></li>
<li><i class="fa fa-flask" aria-hidden="true"></i> <a href="https://neo4j.com/labs/?ref=developer-footer">Neo4j Labs</a></li>
</ul>
</div>
<div class="column links">
<h2>Social</h2>
<ul>
<li><i class="fa fa-twitter" aria-hidden="true"></i> <a rel="noopener" href="https://twitter.com/neo4j" target="_blank">Twitter</a></li>
<li><i class="fa fa-meetup" aria-hidden="true"></i> <a rel="noopener" href="https://www.meetup.com/Neo4j-Online-Meetup/" target="_blank">Meetups</a></li>
<li><i class="fa fa-github" aria-hidden="true"></i> <a rel="noopener" href="https://github.com/neo4j/neo4j" target="_blank">Github</a></li>
<li><i class="fa fa-stack-overflow" aria-hidden="true"></i> <a rel="noopener" href="https://stackoverflow.com/questions/tagged/neo4j" target="_blank">Stack Overflow</a></li>
<li class="speaker-program"><a href="https://docs.google.com/forms/d/e/1FAIpQLSdEcNnMruES5iwvOVYovmS1D_P1ZL_HdUOitFrwrvruv5PZvA/viewform">Want to Speak?</a></li>
</ul>
</div>
</div>
</footer>

View File

@@ -0,0 +1,13 @@
<div id="indexlinkbox">
<h3 id="indexlinklabel">{{ _('Index') }}</h3>
<div class="indexlinkwrapper nav-menu">
<ul>
<li class="toctree-l1">
<a href="{{ pathto('genindex')|e }}" class="indexlink genindex">
{{ _('Index') }}
</a>
</li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,72 @@
{%- extends "basic/layout.html" %}
{% set favicon_url = 'https://neo4j.com/wp-content/themes/neo4jweb/favicon.ico' %}
{# removed existing top+bottom related nav #}
{%- block relbar1 %}{% endblock %}
{%- block relbar2 %}{% endblock %}
{% block extrahead %}
<link href="{{ pathto('_static/css/nunito-sans.css', 1)|e }}" rel="stylesheet">
{% endblock %}
{%- block content %}
<body class="light-mode dark-mode article docs sphinx">
<script>
const userColorSchemeName = 'neo4j-docs-theme';
const userColorScheme = localStorage.getItem(userColorSchemeName) || 'system';
document.documentElement.style.colorScheme = userColorScheme;
</script>
{%- block document %}
<header class="header">
<nav class="navbar">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<img class="navbar-logo" src="https://dist.neo4j.com/wp-content/uploads/20210422142941/neo4j-logo-2020.svg" alt="Neo4j Graph Data Science Client API Reference">
</a>
<a href="{{ pathto(root_doc) }}" class="navbar-item no-left-padding" aria-label="Neo4j Graph Data Science Client API Reference">
Graph Data Science Client API Reference
</a>
</div>
<div id="topbar-nav" class="navbar-menu">
<div class="navbar-start">
</div>
</div>
</nav>
</header>
<div class="body">
{% block sidebar1 %}{{ sidebar() }}{% endblock %}
<main class="article">
<div class="toolbar" role="navigation">
<div class="toolbar-wrapper">
<button class="nav-toggle" aria-label="Toggle Table of Contents"></button>
</div>
</div>
<div class="content">
<article class="doc">
{% block body %} {% endblock %}
<!-- {%- if show_source and has_source and sourcename %}
<a href="{{ pathto('_sources/' + sourcename, true)|e }}"
rel="nofollow">{{ _('Page source') }}</a>
{%- endif %} -->
</article>
</div>
</main>
</div>
{%- endblock %}
{%- endblock %}
{%- block footer %}
{% include "footer.html" %}
{% if disable_tracking != false %}
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WK23PSS');</script>
{% endif %}
{%- endblock %}
</body>

View File

@@ -0,0 +1,11 @@
<div class="nav-container">
<aside class="nav">
<div class="panels">
<div class="nav-panel-menu is-active" data-panel="menu">
<nav class="nav-menu">
{{ toctree(includehidden=theme_sidebar_includehidden, collapse=theme_sidebar_collapse) }}
</nav>
</div>
</div>
</aside>
</div>

View File

@@ -0,0 +1,487 @@
@import "https://neo4j.com/docs/assets/css/site.css";
#auth {
padding-left: initial;
}
.doc h1 {
font-size: 1.75em;
}
.doc p {
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0;
margin-inline-end: 0;
}
.sphinx pre {
line-height: 1.3;
}
.sphinx pre:not(.highlight) {
padding-top: 1rem;
padding-bottom: 1rem;
background: light-dark(var(--theme-light-color-neutral-bg-on-bg-weak), #1a1b1d);
border-radius: 0;
border: 1px solid light-dark(var(--theme-light-color-neutral-border-strongest), var(--theme-dark-color-neutral-border-strongest));
}
html.is-clipped--nav #searchbox {
display: none !important;
}
body .sphinxsidebar {
background: light-dark(var(--palette-neutral-15),var(--theme-dark-color-neutral-bg-weak));
}
body.sphinx a.external::after {
display: inline-block;
content: "";
padding: 0;
margin: 0;
background-position: 50%;
}
body.sphinx #searchbox {
padding: 0 1.5rem 0.5rem;
}
body.sphinx #indexlinkbox {
padding: 0 1.5rem 0.5rem 0;
}
body.sphinx #indexlinkbox .indexlinkwrapper > ul:first-child {
margin-top: 0;
}
#indexlinklabel {
padding-left: 1.5rem;
}
body.sphinx #searchlabel,
body.sphinx #indexlinklabel {
margin: 0.8rem 0 0.5rem;
}
body.sphinx #searchlabel,
body.sphinx #indexlinklabel {
margin: 0.8rem 0 0.5rem;
}
body.sphinx #searchbox .search,
body.sphinx .content .search {
display: block;
opacity: 1;
position: relative;
background: initial;
}
@media screen and (min-width: 1024px) {
body.sphinx .toolbar {
box-shadow: none;
height: 0;
}
.navbar-item, .navbar-link {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
body.sphinx .nav-container {
border: none;
}
body.sphinx .nav,
body.sphinx .nav-panel-menu {
height: auto;
background: initial;
}
body.sphinx .sphinxsidebar {
position: static;
}
body.sphinx .sphinxsidebarwrapper {
position: sticky;
top: 3.77778rem;
height: calc(100vh - 3.77778rem);
overflow-y: auto;
}
body.sphinx .navbar-start {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
max-width: 63.11111rem;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin-right: 2rem;
}
body.sphinx .navbar-start .navbar-link {
margin-left: auto;
}
}
.navbar-item, .navbar-link {
line-height: 1.8;
padding: 0.5rem 1rem;
position: relative;
}
@media screen and (min-width: 769px) {
.doc>.sect-header>h1.page:first-child {
margin-top: 2.5rem;
}
}
.doc>section>h1:first-child {
font-size: 2rem;
margin: 1.5rem 0.5rem 1.5rem 0;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 {
font-weight: 400;
-webkit-hyphens: none;
-ms-hyphens: none;
hyphens: none;
line-height: 1.3;
margin: 2rem 0 1rem;
}
.doc a.headerlink {
visibility: hidden;
margin-left: 0.5rem;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
caption:hover > a.headerlink,
p.caption:hover > a.headerlink,
div.code-block-caption:hover > a.headerlink {
visibility: visible;
}
.nav-menu .caption {
padding: 0.5rem 1.5rem;
font-size: 1.5rem;
}
.nav-menu ul {
padding-left: 0;
}
{% for level in range(1, 4) %}
.nav-menu li.toctree-l{{ level }} {
list-style: none;
position: relative;
}
.nav-menu .toctree-l{{ level }}>a,
.nav-menu .toctree-l{{ level }}>span {
padding-left: {{ level }}.5rem;
}
.nav-menu .toctree-l{{ level }}>a,
.nav-menu .toctree-l{{ level }}>span {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.nav-menu .toctree-l{{ level }} a:hover,
.nav-menu .toctree-l{{ level }} span:hover {
background: light-dark(var(--theme-light-color-neutral-hover), var(--theme-dark-color-primary-hover-weak));
}
.nav-menu .toctree-l{{ level }}>a.current {
background: light-dark(var(--theme-light-color-neutral-hover), var(--theme-dark-color-primary-hover-weak));
color: light-dark(var(--theme-light-color-primary-text), var(--theme-dark-color-primary-text));
}
.nav-menu .toctree-l{{ level }}>a.current::before {
content: "";
width: 4px;
height: 100%;
position: absolute;
left: 0;
top: 0;
border-radius: 4px;
}
.toctree-l{{ level }}>a, .toctree-l{{ level }}>span {
position: relative;
padding-right: 2rem;
}
{% endfor %}
.nav-menu li a code {
font-family: inherit
}
.is-current-page>.nav-link,
.is-current-page>.nav-text {
font-weight: 400;
}
.nav-menu a, .nav-text {
font-weight: 400;
display: block;
padding: 0.25rem 0;
}
/* lists */
body.sphinx .doc ul li{
margin-bottom: 0;
}
/* functions */
body.sphinx .doc dl.py.function {
padding: 0 1rem;
/* border-top: 2px dotted #eee; */
}
/* deprecated */
body.sphinx .deprecated::after,
body.sphinx .deprecated > *::after {
content: unset;
}
body.sphinx .doc dl.deprecated dt:first-of-type span.sig-prename,
body.sphinx .doc dl.deprecated dt:first-of-type span.sig-name {
border-bottom: 1px solid var(--palette-lemon-30);
}
body.sphinx .doc dl.deprecated {
margin-bottom: 0;
padding-bottom: 0;
}
body.sphinx .doc div.deprecated {
padding: 1rem 1rem 0.75rem;
margin: 0.5rem 1.5rem;
border-radius: .25rem;
border-left: 2px solid var(--palette-lemon-30);
}
.sphinx .doc .deprecated > :first-child {
margin-top: 0;
}
.sphinx .doc .deprecated > :last-child {
margin-bottom: 0;
}
b, strong {
font-weight: 800;
}
dt {
font-weight: initial;
}
.sphinx .doc .admonition {
margin: 0.5rem 1.5rem;
border-left: 4px solid #2d3748;
border-radius: .25rem;
padding: 1rem 1rem 0.75rem;
font-size: .88889rem
}
.sphinx .doc .admonition .admonition-title:after {
content: ":";
}
.sphinx .doc .admonition .admonition-title,
.sphinx .doc .admonition .admonition-title + p {
display: inline;
}
.sphinx .doc .admonition > :last-child {
margin-bottom: 0;
}
.sphinx .doc .admonition > table {
border-collapse: collapse;
table-layout: fixed;
position: relative;
width: 100%
}
.sphinx .doc .admonition .content {
padding: 1rem 1rem .75rem;
width: 100%
}
.sphinx .doc .admonition .listingblock .content {
padding: 0
}
.sphinx .doc .admonition .icon {
display: none
}
.sphinx .doc .admonition a.btn {
display: inline-block;
padding: .5rem 2rem;
border-radius: .5rem
color: light-dark(var(--theme-light-color-neutral-text-inverse), var(--theme-dark-color-neutral-text-inverse));
background: light-dark(var(--theme-light-color-primary-text), var(--theme-dark-color-primary-text));
}
.sphinx .doc .admonition a.btn::after {
display: none !important
}
.sphinx .doc .admonition.warning {
background-color: light-dark(var(--theme-light-color-danger-bg-weak), var(--theme-dark-color-danger-bg-weak));
border-color: light-dark(var(--theme-light-color-danger-border-weak), var(--theme-dark-color-danger-border-weak));
}
.sphinx .doc .admonition.warning a {
color: light-dark(var(--theme-light-color-danger-bg-strong), var(--theme-dark-color-danger-bg-strong));
}
.sphinx .doc .admonition.caution {
background-color: light-dark(var(--theme-light-color-warning-bg-weak), var(--theme-dark-color-warning-bg-weak));
border-color: light-dark(var(--theme-light-color-warning-border-weak), var(--theme-dark-color-warning-border-weak));
}
.sphinx .doc .admonition.caution a {
color: light-dark(var(--theme-light-color-warning-bg-strong), var(--theme-dark-color-warning-bg-strong));
}
.sphinx .doc .admonition.tip, .sphinx .doc .admonition.note {
background-color: light-dark(var(--theme-light-color-success-bg-weak), var(--theme-dark-color-success-bg-weak));
border-left-color: light-dark(var(--theme-light-color-success-border-weak), var(--theme-dark-color-success-border-weak));
}
.sphinx .doc .admonition.tip a, .sphinx .doc .admonition.note a {
color: light-dark(var(--theme-light-color-success-bg-strong), var(--theme-dark-color-success-bg-strong));
}
.sphinx .doc .admonition.seealso {
background-color: light-dark(var(--palette-lavender-10), var(--palette-lavender-70));
border-left-color: var(--palette-lavender-20);
}
.sphinx .doc .admonition.important {
background-color: light-dark(var(--palette-lavender-10), var(--palette-lavender-70));
border-left-color: var(--palette-lavender-20);
}
.sphinx .doc .admonition.important a {
color: light-dark(var(--palette-lavender-70), var(--palette-lavender-10));
}
dd > :first-child {
margin-top: 0;
}
.field-list p {
margin: 0;
}
dl.field-list {
display: grid;
grid-template-columns: fit-content(30%) auto;
}
dl.field-list > dt {
font-weight: bold;
/*word-break: break-word;*/
padding-left: 0.5em;
padding-right: 5px;
}
dl.field-list > dd {
padding-left: 0.5em;
margin-left: 0;
}
dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
}
dl.field-list > dd > ul,
dl.field-list > dd > ol {
padding-left: 1.9em;
margin-left: 0;
}
.content ol li > p:first-of-type,
.content ul li > p:first-of-type {
margin-top: 0;
}
.content ol li > p:last-of-type,
.content ul li > p:last-of-type {
margin-bottom: 0;
}
table.docutils {
margin-top: 10px;
margin-bottom: 10px;
border: 0;
border-collapse: collapse;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border: 0;
}
table.docutils > tbody > tr:not(:last-child) > td,
table.docutils > tbody > tr:not(:last-child) > td,
table.docutils > thead > tr:not(:last-child) > td,
table.docutils > thead > tr:not(:last-child) > td,
table.docutils > tr:not(:last-child) > td,
table.docutils > tr:not(:last-child) > td {
border-bottom: 1px solid #aaa;
}
th > :first-child,
td > :first-child {
margin-top: 0;
}
th > :last-child,
td > :last-child {
margin-bottom: 0;
}
.sig-name, code.descname {
font-weight: bold;
}
.sig-paren {
font-size: larger;
}
.versionmodified {
font-style: italic;
}

View File

@@ -0,0 +1,200 @@
/* cyrillic-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 300;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 300;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 300;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 300;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin-ext.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 300;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin-ext.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin-ext.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-cyrillic.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin-ext.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Nunito Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(../fonts/nunito-sans-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

View File

@@ -0,0 +1,53 @@
;(function () {
'use strict'
var article = document.querySelector('article.doc')
var cheatSheet = document.querySelector('body.cheat-sheet')
var toolbar = document.querySelector('.toolbar')
var headerNavigationBar = document.querySelector('header > .navbar')
function decodeFragment (hash) {
return hash && (~hash.indexOf('%') ? decodeURIComponent(hash) : hash).slice(1)
}
function computePosition (el, sum) {
if (article.contains(el)) {
return computePosition(el.offsetParent, el.offsetTop + sum)
} else {
return sum
}
}
function jumpToAnchor (e) {
if (e) {
window.location.hash = '#' + this.id
e.preventDefault()
}
var topOffset = toolbar ? toolbar.getBoundingClientRect().bottom : headerNavigationBar.getBoundingClientRect().bottom
if (cheatSheet) {
var scrollTarget = this.closest('div')
var selectorsTop = document.querySelector('.nav-container .selectors').querySelector('div').getBoundingClientRect().top
if (this.tagName === 'H3') topOffset = selectorsTop
window.scrollTo(0, computePosition(scrollTarget, 0) - topOffset)
} else {
window.scrollTo(0, computePosition(this, 0) - topOffset)
}
}
window.addEventListener('load', function jumpOnLoad (e) {
var fragment, target
if ((fragment = decodeFragment(window.location.hash)) && (target = document.getElementById(fragment))) {
jumpToAnchor.bind(target)()
setTimeout(jumpToAnchor.bind(target), 0)
}
window.removeEventListener('load', jumpOnLoad)
})
Array.prototype.slice.call(document.querySelectorAll('a[href^="#"]')).forEach(function (el) {
var fragment, target
if ((fragment = decodeFragment(el.hash)) && (target = document.getElementById(fragment))) {
el.addEventListener('click', jumpToAnchor.bind(target))
}
})
})()

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M35 19.772h55" fill="none" stroke="#222" stroke-width="8" stroke-opacity=".941"/><path fill="#222" d="M10 12.272h15v15H10z"/><path d="M43 63.678h45" fill="none" stroke="#222" stroke-width="5" stroke-opacity=".941"/><path fill="#222" d="M23 58.677h10v10H23z"/><path d="M43 82.727h45" fill="none" stroke="#222" stroke-width="5" stroke-opacity=".941"/><path fill="#222" d="M23 77.727h10v10H23z"/><path d="M43 44.628h45" fill="none" stroke="#222" stroke-width="5" stroke-opacity=".941"/><path fill="#222" d="M23 39.628h10v10H23z"/></svg>

After

Width:  |  Height:  |  Size: 605 B

View File

@@ -0,0 +1,9 @@
[theme]
inherit = basic
stylesheet = css/neo4j.css
pygments_style = sphinx
sidebars = navigation.html, searchbox.html, indexnav.html
[options]
sidebar_includehidden = false
sidebar_collapse = false

View File

@@ -0,0 +1,223 @@
.. _types-documentation:
*****
Types
*****
RawSearchResult
===============
.. autoclass:: neo4j_graphrag.types.RawSearchResult
RetrieverResult
===============
.. autoclass:: neo4j_graphrag.types.RetrieverResult
RetrieverResultItem
===================
.. autoclass:: neo4j_graphrag.types.RetrieverResultItem
LLMUsage
========
.. autoclass:: neo4j_graphrag.llm.types.LLMUsage
LLMResponse
===========
.. autoclass:: neo4j_graphrag.llm.types.LLMResponse
LLMMessage
===========
.. autoclass:: neo4j_graphrag.types.LLMMessage
RagResultModel
==============
.. autoclass:: neo4j_graphrag.generation.types.RagResultModel
DocumentInfo
============
.. autoclass:: neo4j_graphrag.experimental.components.types.DocumentInfo
LoadedDocument
==============
.. autoclass:: neo4j_graphrag.experimental.components.types.LoadedDocument
TextChunk
=========
.. autoclass:: neo4j_graphrag.experimental.components.types.TextChunk
TextChunks
==========
.. autoclass:: neo4j_graphrag.experimental.components.types.TextChunks
Neo4jNode
=========
.. autoclass:: neo4j_graphrag.experimental.components.types.Neo4jNode
Neo4jRelationship
=================
.. autoclass:: neo4j_graphrag.experimental.components.types.Neo4jRelationship
Neo4jGraph
==========
.. autoclass:: neo4j_graphrag.experimental.components.types.Neo4jGraph
GeoPoint
========
.. autoclass:: neo4j_graphrag.experimental.components.types.GeoPoint
KGWriterModel
=============
.. autoclass:: neo4j_graphrag.experimental.components.kg_writer.KGWriterModel
PropertyType
============
.. autoclass:: neo4j_graphrag.experimental.components.schema.PropertyType
NodeType
========
.. autoclass:: neo4j_graphrag.experimental.components.schema.NodeType
RelationshipType
================
.. autoclass:: neo4j_graphrag.experimental.components.schema.RelationshipType
Pattern
=======
.. autoclass:: neo4j_graphrag.experimental.components.schema.Pattern
GraphConstraintType
=====================
.. autoclass:: neo4j_graphrag.experimental.components.schema.GraphConstraintType
ConstraintType
================
.. autoclass:: neo4j_graphrag.experimental.components.schema.ConstraintType
GraphSchema
===========
.. autoclass:: neo4j_graphrag.experimental.components.schema.GraphSchema
LexicalGraphConfig
===================
.. autoclass:: neo4j_graphrag.experimental.components.types.LexicalGraphConfig
Neo4jDriverType
===============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverType
Neo4jDriverConfig
=================
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverConfig
LLMType
=======
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.LLMType
LLMConfig
=========
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.LLMConfig
EmbedderType
============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderType
EmbedderConfig
==============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.EmbedderConfig
ComponentType
=============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.ComponentType
ComponentConfig
===============
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.object_config.ComponentConfig
ParamFromEnvConfig
==================
.. autoclass:: neo4j_graphrag.experimental.pipeline.config.param_resolver.ParamFromEnvConfig
EventType
=========
.. autoenum:: neo4j_graphrag.experimental.pipeline.notification.EventType
PipelineEvent
==============
.. autoclass:: neo4j_graphrag.experimental.pipeline.notification.PipelineEvent
TaskEvent
==============
.. autoclass:: neo4j_graphrag.experimental.pipeline.notification.TaskEvent
EventCallbackProtocol
=====================
.. autoclass:: neo4j_graphrag.experimental.pipeline.notification.EventCallbackProtocol
:members: __call__
TaskProgressCallbackProtocol
============================
.. autoclass:: neo4j_graphrag.experimental.pipeline.types.context.TaskProgressNotifierProtocol
:members: __call__
RunContext
==========
.. autoclass:: neo4j_graphrag.experimental.pipeline.types.context.RunContext

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
.. _user-guide-pipeline:
User Guide: Pipeline
####################
This page provides information about how to create a pipeline.
.. note::
Pipelines run asynchronously, see examples below.
*******************
Creating Components
*******************
Components are asynchronous units of work that perform simple tasks,
such as chunking documents or saving results to Neo4j.
This package includes a few default components, but developers can create
their own by following these steps:
1. Create a subclass of the Pydantic `neo4j_graphrag.experimental.pipeline.DataModel` to represent the data being returned by the component
2. Create a subclass of `neo4j_graphrag.experimental.pipeline.Component`
3. Create a `run` method in this new class and specify the required inputs and output model using the just created `DataModel`
4. Implement the run method: it's an `async` method, allowing tasks to be parallelized and awaited within this method.
An example is given below, where a `ComponentAdd` is created to add two numbers together and return
the resulting sum:
.. code:: python
from neo4j_graphrag.experimental.pipeline import Component, DataModel
class IntResultModel(DataModel):
result: int
class ComponentAdd(Component):
async def run(self, number1: int, number2: int = 1) -> IntResultModel:
return IntResultModel(result = number1 + number2)
Read more about :ref:`components-section` in the API Documentation.
***************************************
Connecting Components within a Pipeline
***************************************
The ultimate aim of creating components is to assemble them into a complex pipeline
for a specific purpose, such as building a Knowledge Graph from text data.
Here's how to create a simple pipeline and propagate results from one component to another
(detailed explanations follow):
.. code:: python
import asyncio
from neo4j_graphrag.experimental.pipeline import Pipeline
pipe = Pipeline()
pipe.add_component(ComponentAdd(), "a")
pipe.add_component(ComponentAdd(), "b")
pipe.connect("a", "b", input_config={"number2": "a.result"})
asyncio.run(pipe.run({"a": {"number1": 10, "number2": 1}, "b": {"number1": 4}}))
# result: 10+1+4 = 15
1. First, a pipeline is created, and two components named "a" and "b" are added to it.
2. Next, the two components are connected so that "b" runs after "a", with the "number2" parameter for component "b" being the result of component "a".
3. Finally, the pipeline is run with 10 and 1 as input parameters for "a". Component "b" will receive 11 (10 + 1, the result of "a") as "number1" and 4 as "number2" (as specified in the pipeline.run parameters).
The data flow is illustrated in the diagram below:
.. code-block::
10 ---\
Component "a" -> 11
1 ----/ \
\
Component "b" -> 15
4 -------------------------/
.. warning:: Cyclic graph
Cycles are not allowed in a Pipeline.
.. warning:: Ignored user inputs
If inputs are provided both by user in the `pipeline.run` method and as
`input_config` in a connect method, the user input will be ignored. Take for
instance the following pipeline, adapted from the previous one:
.. code:: python
pipe.connect("a", "b", input_config={"number2": "a.result"})
asyncio.run(pipe.run({"a": {"number1": 10, "number2": 1}, "b": {"number1": 4, "number2": 42}}))
The result will still be **15** because the user input `"number2": 42` is ignored.
**********************
Visualising a Pipeline
**********************
Pipelines can be visualized using the `draw` method:
.. code:: python
from neo4j_graphrag.experimental.pipeline import Pipeline
pipe = Pipeline()
# ... define components and connections
pipe.draw("pipeline.html")
Here is an example pipeline rendering as an interactive HTML visualization:
.. code:: python
# To view the visualization in a browser
import webbrowser
webbrowser.open("pipeline.html")
By default, output fields which are not mapped to any component are hidden. They
can be added to the visualization by setting `hide_unused_outputs` to `False`:
.. code:: python
pipe.draw("pipeline_full.html", hide_unused_outputs=False)
# To view the full visualization in a browser
import webbrowser
webbrowser.open("pipeline_full.html")
************************
Adding an Event Callback
************************
It is possible to add a callback to receive notification about pipeline progress:
- `PIPELINE_STARTED`, when pipeline starts
- `PIPELINE_FINISHED`, when pipeline ends
- `TASK_STARTED`, when a task starts
- `TASK_PROGRESS`, sent by each component (depends on component's implementation, see below)
- `TASK_FINISHED`, when a task ends
See :ref:`pipelineevent` and :ref:`taskevent` to see what is sent in each event type.
.. code:: python
import asyncio
import logging
from neo4j_graphrag.experimental.pipeline import Pipeline
from neo4j_graphrag.experimental.pipeline.notification import Event
logger = logging.getLogger(__name__)
logging.basicConfig()
logger.setLevel(logging.WARNING)
async def event_handler(event: Event) -> None:
"""Function can do anything about the event,
here we're just logging it if it's a pipeline-level event.
"""
if event.event_type.is_pipeline_event:
logger.warning(event)
pipeline = Pipeline(
callback=event_handler,
)
# ... add components, connect them as usual
await pipeline.run(...)
Send Events from Components
===========================
Components can send progress notifications using the `notify` function from
`context_` by implementing the `run_from_context` method:
.. code:: python
from neo4j_graphrag.experimental.pipeline import Component, DataModel
from neo4j_graphrag.experimental.pipeline.types.context import RunContext
class IntResultModel(DataModel):
result: int
class ComponentAdd(Component):
async def run_with_context(self, context_: RunContext, number1: int, number2: int = 1) -> IntResultModel:
for fake_iteration in range(10):
await context_.notify(
message=f"Starting iteration {fake_iteration} out of 10",
data={"iteration": fake_iteration, "total": 10}
)
return IntResultModel(result = number1 + number2)
This will send an `TASK_PROGRESS` event to the pipeline callback.
.. note::
In a future release, the `context_` parameter will be added to the `run` method.

File diff suppressed because it is too large Load Diff