Skip to content

Commit

Permalink
Merge branch 'feature/config-files' of https://github.com/stellasia/n…
Browse files Browse the repository at this point in the history
…eo4j-graphrag-python into feature/config-files
  • Loading branch information
stellasia committed Dec 12, 2024
2 parents 54a55ae + 8572b42 commit 94483d8
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 21 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ FilterValidationError


EmbeddingsGenerationError
========================
=========================

.. autoclass:: neo4j_graphrag.exceptions.EmbeddingsGenerationError
:show-inheritance:
Expand Down
30 changes: 30 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://pygraphviz.github.io/documentation/stable/install.html>`_.


********
Examples
********
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/embeddings/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/embeddings/mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/embeddings/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/embeddings/sentence_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/embeddings/vertexai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/llm/anthropic_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/llm/cohere_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/llm/mistralai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/llm/openai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j_graphrag/llm/vertexai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 94483d8

Please sign in to comment.