@@ -76,7 +76,7 @@ This package currently supports text extraction from PDFs:
76
76
from neo4j_graphrag.experimental.components.pdf_loader import PdfLoader
77
77
78
78
loader = PdfLoader()
79
- loader.run(path = Path(" my_file.pdf" ))
79
+ await loader.run(path = Path(" my_file.pdf" ))
80
80
81
81
To implement your own loader, use the `DataLoader ` interface:
82
82
@@ -115,7 +115,7 @@ Wrappers for LangChain and LlamaIndex text splitters are included in this packag
115
115
splitter = LangChainTextSplitterAdapter(
116
116
CharacterTextSplitter(chunk_size = 4000 , chunk_overlap = 200 , separator = " ." )
117
117
)
118
- splitter.run(text = " Hello World. Life is beautiful." )
118
+ await splitter.run(text = " Hello World. Life is beautiful." )
119
119
120
120
121
121
Also see :ref: `langchaintextsplitteradapter ` and :ref: `llamaindextextsplitteradapter `.
@@ -155,7 +155,7 @@ Example usage:
155
155
from neo4j_graphrag.experimental.components.embedder import TextChunkEmbedder
156
156
from neo4j_graphrag.embeddings.openai import OpenAIEmbeddings
157
157
text_chunk_embedder = TextChunkEmbedder(embedder = OpenAIEmbeddings())
158
- text_chunk_embedder.run(text_chunks = TextChunks(chunks = [TextChunk(text = " my_text" )]))
158
+ await text_chunk_embedder.run(text_chunks = TextChunks(chunks = [TextChunk(text = " my_text" )]))
159
159
160
160
.. note ::
161
161
@@ -257,6 +257,8 @@ It can be used in this way:
257
257
},
258
258
)
259
259
)
260
+ await extractor.run(chunks = TextChunks(chunks = [TextChunk(text = " some text" )]))
261
+
260
262
261
263
.. warning ::
262
264
@@ -322,12 +324,12 @@ The default prompt uses the :ref:`erextractiontemplate`. It is possible to provi
322
324
323
325
extractor = LLMEntityRelationExtractor(
324
326
llm = ... .,
325
- prompt = " this is my prompt " ,
327
+ prompt = " Extract entities from {text} " ,
326
328
)
327
329
328
330
The following variables can be used in the prompt:
329
331
330
- - `text ` (str): the text to be analyzed.
332
+ - `text ` (str): the text to be analyzed (mandatory) .
331
333
- `schema ` (str): the graph schema to be used.
332
334
- `examples ` (str): examples for few-shot learning.
333
335
@@ -351,17 +353,17 @@ If more customization is needed, it is possible to subclass the `EntityRelationE
351
353
352
354
class MyExtractor (EntityRelationExtractor ):
353
355
354
- @validate_call
355
- async def run (self , chunks : TextChunks, ** kwargs : Any) -> Neo4jGraph:
356
- return Neo4jGraph(
357
- nodes = [
358
- Neo4jNode(id = " 0" , label = " Person" , properties = {" name" : " A. Einstein" }),
359
- Neo4jNode(id = " 1" , label = " Concept" , properties = {" name" : " Theory of relativity" }),
360
- ],
361
- relationships = [
362
- Neo4jRelationship(type = " PROPOSED_BY" , start_node_id = " 1" , end_node_id = " 0" , properties = {" year" : 1915 })
363
- ],
364
- )
356
+ @validate_call
357
+ async def run (self , chunks : TextChunks, ** kwargs : Any) -> Neo4jGraph:
358
+ return Neo4jGraph(
359
+ nodes = [
360
+ Neo4jNode(id = " 0" , label = " Person" , properties = {" name" : " A. Einstein" }),
361
+ Neo4jNode(id = " 1" , label = " Concept" , properties = {" name" : " Theory of relativity" }),
362
+ ],
363
+ relationships = [
364
+ Neo4jRelationship(type = " PROPOSED_BY" , start_node_id = " 1" , end_node_id = " 0" , properties = {" year" : 1915 })
365
+ ],
366
+ )
365
367
366
368
367
369
See :ref: `entityrelationextractor `.
@@ -385,7 +387,7 @@ to a Neo4j database:
385
387
) as driver:
386
388
writer = Neo4jWriter(driver)
387
389
graph = Neo4jGraph(nodes = [], relationships = [])
388
- asyncio.run( writer.run() )
390
+ await writer.run(graph )
389
391
390
392
See :ref: `neo4jgraph ` for the description of the input type.
391
393
0 commit comments