diff --git a/README.md b/README.md index 2c5cd53b4..9fb37a0e7 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,32 @@ pip install neo4j-graphrag ### Optional Dependencies +This package has some optional features that can be enabled using +the extra dependencies described below: + +- LLM providers (at least one is required for RAG and KG Builder Pipeline): + - **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 such as the Knowledge Graph creation pipelines. + - Warning: this dependency group requires `pygraphviz`. See below for installation instructions. + + +Install package with optional dependencies with (for instance): + +```shell +pip install "neo4j-graphrag[openai]" +# or +pip install "neo4j-graphrag[openai, experimental]" +``` + #### pygraphviz `pygraphviz` is used for visualizing pipelines. diff --git a/docs/source/api.rst b/docs/source/api.rst index 68a0884ab..d1b1066dd 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -416,7 +416,7 @@ FilterValidationError EmbeddingsGenerationError -======================== +========================= .. autoclass:: neo4j_graphrag.exceptions.EmbeddingsGenerationError :show-inheritance: diff --git a/docs/source/index.rst b/docs/source/index.rst index df94a0669..9d6f9a3de 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -72,6 +72,36 @@ To install the latest stable version, use: 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]" + # or + pip install "neo4j-graphrag[openai, experimental]" + + +List of extra dependencies: + +- LLM providers (at least one is required for RAG and KG Builder Pipeline): + - **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 such as the Knowledge Graph creation pipelines. + - Warning: this requires `pygraphviz`. Installation instructions can be found `here `_. + + ******** Examples ******** diff --git a/src/neo4j_graphrag/embeddings/cohere.py b/src/neo4j_graphrag/embeddings/cohere.py index 3289ee3f8..63906a5e0 100644 --- a/src/neo4j_graphrag/embeddings/cohere.py +++ b/src/neo4j_graphrag/embeddings/cohere.py @@ -28,8 +28,8 @@ class CohereEmbeddings(Embedder): def __init__(self, model: str = "", **kwargs: Any) -> None: if cohere is None: raise ImportError( - "Could not import cohere python client. " - "Please install it with `pip install cohere`." + """Could not import cohere python client. + Please install it with `pip install "neo4j-graphrag[cohere]"`.""" ) self.model = model self.client = cohere.Client(**kwargs) diff --git a/src/neo4j_graphrag/embeddings/mistral.py b/src/neo4j_graphrag/embeddings/mistral.py index 5a9c76a06..8c3522634 100644 --- a/src/neo4j_graphrag/embeddings/mistral.py +++ b/src/neo4j_graphrag/embeddings/mistral.py @@ -39,8 +39,8 @@ class MistralAIEmbeddings(Embedder): def __init__(self, model: str = "mistral-embed", **kwargs: Any) -> None: if Mistral is None: raise ImportError( - "Could not import mistralai. " - "Please install it with `pip install mistralai`." + """Could not import mistralai. + Please install it with `pip install "neo4j-graphrag[mistralai]"`.""" ) api_key = kwargs.pop("api_key", None) if api_key is None: diff --git a/src/neo4j_graphrag/embeddings/openai.py b/src/neo4j_graphrag/embeddings/openai.py index 6204acb3a..4a4d60387 100644 --- a/src/neo4j_graphrag/embeddings/openai.py +++ b/src/neo4j_graphrag/embeddings/openai.py @@ -36,8 +36,8 @@ def __init__(self, model: str = "text-embedding-ada-002", **kwargs: Any) -> None import openai except ImportError: raise ImportError( - "Could not import openai python client. " - "Please install it with `pip install openai`." + """Could not import openai python client. + Please install it with `pip install "neo4j-graphrag[openai]"`.""" ) self.openai = openai self.model = model diff --git a/src/neo4j_graphrag/embeddings/sentence_transformers.py b/src/neo4j_graphrag/embeddings/sentence_transformers.py index 3e0f92024..f30ed5b7f 100644 --- a/src/neo4j_graphrag/embeddings/sentence_transformers.py +++ b/src/neo4j_graphrag/embeddings/sentence_transformers.py @@ -28,8 +28,8 @@ def __init__( import torch except ImportError: raise ImportError( - "Could not import sentence_transformers python package. " - "Please install it with `pip install sentence-transformers`." + """Could not import sentence_transformers python package. + Please install it with `pip install "neo4j-graphrag[sentence-transformers]"`.""" ) self.torch = torch self.np = np diff --git a/src/neo4j_graphrag/embeddings/vertexai.py b/src/neo4j_graphrag/embeddings/vertexai.py index c04c665ed..5aecdcfad 100644 --- a/src/neo4j_graphrag/embeddings/vertexai.py +++ b/src/neo4j_graphrag/embeddings/vertexai.py @@ -36,8 +36,8 @@ class VertexAIEmbeddings(Embedder): def __init__(self, model: str = "text-embedding-004") -> None: if vertexai is None: raise ImportError( - "Could not import Vertex AI Python client. " - "Please install it with `pip install google-cloud-aiplatform`." + """Could not import Vertex AI Python client. + Please install it with `pip install "neo4j-graphrag[google]"`.""" ) self.vertexai_model = ( vertexai.language_models.TextEmbeddingModel.from_pretrained(model) diff --git a/src/neo4j_graphrag/llm/anthropic_llm.py b/src/neo4j_graphrag/llm/anthropic_llm.py index fd076c0f7..e8f551cb3 100644 --- a/src/neo4j_graphrag/llm/anthropic_llm.py +++ b/src/neo4j_graphrag/llm/anthropic_llm.py @@ -55,8 +55,8 @@ def __init__( import anthropic except ImportError: raise ImportError( - "Could not import Anthropic Python client. " - "Please install it with `pip install anthropic`." + """Could not import Anthropic Python client. + Please install it with `pip install "neo4j-graphrag[anthropic]"`.""" ) super().__init__(model_name, model_params) self.anthropic = anthropic diff --git a/src/neo4j_graphrag/llm/cohere_llm.py b/src/neo4j_graphrag/llm/cohere_llm.py index 6a6aa0367..aeddafd39 100644 --- a/src/neo4j_graphrag/llm/cohere_llm.py +++ b/src/neo4j_graphrag/llm/cohere_llm.py @@ -53,8 +53,8 @@ def __init__( import cohere except ImportError: raise ImportError( - "Could not import cohere python client. " - "Please install it with `pip install cohere`." + """Could not import cohere python client. + Please install it with `pip install "neo4j-graphrag[cohere]"`.""" ) self.cohere = cohere diff --git a/src/neo4j_graphrag/llm/mistralai_llm.py b/src/neo4j_graphrag/llm/mistralai_llm.py index a9f88aeaa..b9254ffe9 100644 --- a/src/neo4j_graphrag/llm/mistralai_llm.py +++ b/src/neo4j_graphrag/llm/mistralai_llm.py @@ -53,8 +53,8 @@ def __init__( """ if Mistral is None: raise ImportError( - "Could not import Mistral Python client. " - "Please install it with `pip install mistralai`." + """Could not import Mistral Python client. + Please install it with `pip install "neo4j-graphrag[mistralai]"`.""" ) super().__init__(model_name, model_params) api_key = kwargs.pop("api_key", None) diff --git a/src/neo4j_graphrag/llm/openai_llm.py b/src/neo4j_graphrag/llm/openai_llm.py index 04f3f2bf9..9de5071f4 100644 --- a/src/neo4j_graphrag/llm/openai_llm.py +++ b/src/neo4j_graphrag/llm/openai_llm.py @@ -50,8 +50,8 @@ def __init__( import openai except ImportError: raise ImportError( - "Could not import openai Python client. " - "Please install it with `pip install openai`." + """Could not import openai Python client. + Please install it with `pip install "neo4j-graphrag[openai]"`.""" ) self.openai = openai super().__init__(model_name, model_params) diff --git a/src/neo4j_graphrag/llm/vertexai_llm.py b/src/neo4j_graphrag/llm/vertexai_llm.py index b0820e623..dff5e1cfb 100644 --- a/src/neo4j_graphrag/llm/vertexai_llm.py +++ b/src/neo4j_graphrag/llm/vertexai_llm.py @@ -59,8 +59,8 @@ def __init__( ): if GenerativeModel is None or ResponseValidationError is None: raise ImportError( - "Could not import Vertex AI Python client. " - "Please install it with `pip install google-cloud-aiplatform`." + """Could not import Vertex AI Python client. + Please install it with `pip install "neo4j-graphrag[google]"`.""" ) super().__init__(model_name, model_params) self.model = GenerativeModel(model_name=model_name, **kwargs)