Skip to content

Commit d7d6674

Browse files
authored
Fix example in doc and make it more explicit that openai is required to run the examples (#258)
1 parent 7dc71f9 commit d7d6674

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import asyncio
9898
from neo4j import GraphDatabase
9999
from neo4j_graphrag.embeddings import OpenAIEmbeddings
100100
from neo4j_graphrag.experimental.pipeline.kg_builder import SimpleKGPipeline
101-
from neo4j_graphrag.llm.openai_llm import OpenAILLM
101+
from neo4j_graphrag.llm import OpenAILLM
102102

103103
NEO4J_URI = "neo4j://localhost:7687"
104104
NEO4J_USERNAME = "neo4j"
@@ -149,6 +149,9 @@ asyncio.run(kg_builder.run_async(text=text))
149149
driver.close()
150150
```
151151

152+
> Warning: In order to run this code, the `openai` Python package needs to be installed: `pip install "neo4j_graphrag[openai]"`
153+
154+
152155
Example knowledge graph created using the above script:
153156

154157
![Example knowledge graph](https://raw.githubusercontent.com/neo4j/neo4j-graphrag-python/fd276af0069e4dd1769255d358793cc96e299bf3/images/kg_construction.svg)

docs/source/user_guide_kg_builder.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ can be omitted (the parser will automatically import from `neo4j_graphrag.llm`).
357357
For custom implementations, the full path must be explicitly specified,
358358
for example: `my_package.my_llm.MyLLM`.
359359

360+
.. warning::
361+
362+
Check the :ref:`installation` section to make sure you have the required dependencies installed when using an LLM.
363+
364+
360365
Defining an Embedder
361366
--------------------
362367

@@ -800,7 +805,7 @@ It can be used in this way:
800805
from neo4j_graphrag.experimental.components.entity_relation_extractor import (
801806
LLMEntityRelationExtractor,
802807
)
803-
from neo4j_graphrag.llm.openai import OpenAILLM
808+
from neo4j_graphrag.llm import OpenAILLM
804809
805810
extractor = LLMEntityRelationExtractor(
806811
llm=OpenAILLM(
@@ -814,6 +819,10 @@ It can be used in this way:
814819
await extractor.run(chunks=TextChunks(chunks=[TextChunk(text="some text")]))
815820
816821
822+
.. warning::
823+
824+
Using `OpenAILLM` requires the `openai` Python client. You can install it with `pip install "neo4j_graphrag[openai]"`.
825+
817826
.. warning::
818827

819828
The `LLMEntityRelationExtractor` works better if `"response_format": {"type": "json_object"}` is in the model parameters.
@@ -834,13 +843,7 @@ This behaviour can be changed by using the `on_error` flag in the `LLMEntityRela
834843
)
835844
836845
extractor = LLMEntityRelationExtractor(
837-
llm=OpenAILLM(
838-
model_name="gpt-4o",
839-
model_params={
840-
"max_tokens": 1000,
841-
"response_format": {"type": "json_object"},
842-
},
843-
),
846+
# ...
844847
on_error=OnError.RAISE,
845848
)
846849

docs/source/user_guide_rag.rst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ In practice, it's done with only a few lines of code:
5656
print(response.answer)
5757
5858
59-
.. note::
59+
.. warning::
6060

61-
In order to run this code, the `openai` Python package needs to be installed:
62-
`pip install openai`
61+
Using `OpenAILLM` requires the `openai` Python client. You can install it with `pip install "neo4j_graphrag[openai]"`.
6362

6463

6564
The following sections provide more details about how to customize this code.
@@ -108,7 +107,7 @@ to learn more about the configuration.
108107
.. note::
109108

110109
In order to run this code, the `openai` Python package needs to be installed:
111-
`pip install openai`
110+
`pip install "neo4j_graphrag[openai]"`
112111

113112

114113
See :ref:`azureopenaillm`.
@@ -134,7 +133,7 @@ To use VertexAI, instantiate the `VertexAILLM` class:
134133
.. note::
135134

136135
In order to run this code, the `google-cloud-aiplatform` Python package needs to be installed:
137-
`pip install google-cloud-aiplatform`
136+
`pip install "neo4j_grpahrag[vertexai]"`
138137

139138

140139
See :ref:`vertexaillm`.
@@ -160,7 +159,7 @@ To use Anthropic, instantiate the `AnthropicLLM` class:
160159
.. note::
161160

162161
In order to run this code, the `anthropic` Python package needs to be installed:
163-
`pip install anthropic`
162+
`pip install "neo4j_graphrag[anthropic]"`
164163

165164
See :ref:`anthropicllm`.
166165

@@ -184,7 +183,7 @@ To use MistralAI, instantiate the `MistralAILLM` class:
184183
.. note::
185184

186185
In order to run this code, the `mistralai` Python package needs to be installed:
187-
`pip install mistralai`
186+
`pip install "neo4j_graphrag[mistralai]"`
188187

189188
See :ref:`mistralaillm`.
190189

@@ -209,7 +208,7 @@ To use Cohere, instantiate the `CohereLLM` class:
209208
.. note::
210209

211210
In order to run this code, the `cohere` Python package needs to be installed:
212-
`pip install cohere`
211+
`pip install "neo4j_graphrag[cohere]"`
213212

214213

215214
See :ref:`coherellm`.
@@ -630,7 +629,7 @@ Weaviate Retrievers
630629
.. note::
631630

632631
In order to import this retriever, the Weaviate Python client must be installed:
633-
`pip install weaviate-client`
632+
`pip install "neo4j_graphrag[weaviate]"`
634633

635634

636635
.. code:: python
@@ -663,7 +662,7 @@ Pinecone Retrievers
663662
.. note::
664663

665664
In order to import this retriever, the Pinecone Python client must be installed:
666-
`pip install pinecone-client`
665+
`pip install "neo4j_graphrag[pinecone]"`
667666

668667

669668
.. code:: python
@@ -691,7 +690,7 @@ Qdrant Retrievers
691690
.. note::
692691

693692
In order to import this retriever, the Qdrant Python client must be installed:
694-
`pip install qdrant-client`
693+
`pip install "neo4j_graphrag[qdrant]"`
695694

696695

697696
.. code:: python
@@ -787,7 +786,7 @@ LLMs can be different.
787786
788787
from neo4j import GraphDatabase
789788
from neo4j_graphrag.retrievers import Text2CypherRetriever
790-
from neo4j_graphrag.llm.openai import OpenAILLM
789+
from neo4j_graphrag.llm import OpenAILLM
791790
792791
URI = "neo4j://localhost:7687"
793792
AUTH = ("neo4j", "password")
@@ -796,7 +795,7 @@ LLMs can be different.
796795
driver = GraphDatabase.driver(URI, auth=AUTH)
797796
798797
# Create LLM object
799-
llm = OpenAILLM(model_name="gpt-3.5-turbo")
798+
llm = OpenAILLM(model_name="gpt-4o")
800799
801800
# (Optional) Specify your own Neo4j schema
802801
neo4j_schema = """
@@ -833,6 +832,10 @@ LLMs can be different.
833832
print(retriever.search(query_text=query_text))
834833
835834
835+
.. warning::
836+
837+
Using `OpenAILLM` requires the `openai` Python client. You can install it with `pip install "neo4j_graphrag[openai]"`.
838+
836839
.. note::
837840

838841
Since we are not performing any similarity search (vector index), the Text2Cypher

examples/build_graph/simple_kg_builder_from_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from neo4j_graphrag.experimental.pipeline.kg_builder import SimpleKGPipeline
1616
from neo4j_graphrag.experimental.pipeline.pipeline import PipelineResult
1717
from neo4j_graphrag.llm import LLMInterface
18-
from neo4j_graphrag.llm.openai_llm import OpenAILLM
18+
from neo4j_graphrag.llm import OpenAILLM
1919

2020
# Neo4j db infos
2121
URI = "neo4j://localhost:7687"

examples/build_graph/simple_kg_builder_from_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
RelationInputType,
2020
)
2121
from neo4j_graphrag.llm import LLMInterface
22-
from neo4j_graphrag.llm.openai_llm import OpenAILLM
22+
from neo4j_graphrag.llm import OpenAILLM
2323

2424
logging.basicConfig()
2525
logging.getLogger("neo4j_graphrag").setLevel(logging.DEBUG)

0 commit comments

Comments
 (0)