diff --git a/docs/source/user_guide_kg_builder.rst b/docs/source/user_guide_kg_builder.rst index 65ccbd82d..55f0e4bea 100644 --- a/docs/source/user_guide_kg_builder.rst +++ b/docs/source/user_guide_kg_builder.rst @@ -602,9 +602,15 @@ To implement your own loader, use the `DataLoader` interface: from neo4j_graphrag.experimental.components.pdf_loader import DataLoader, PdfDocument class MyDataLoader(DataLoader): - async def run(self, path: Path) -> PdfDocument: - # process file in `path` - return PdfDocument(text="text") + async def run(self, filepath: Path, metadata: Optional[Dict[str, str]] = None) -> PdfDocument: + # process file in `filepath` + return PdfDocument( + text="text", + document_info=DocumentInfo( + path=str(filepath), + metadata=metadata, + ) + ) diff --git a/examples/customize/build_graph/components/loaders/custom_loader.py b/examples/customize/build_graph/components/loaders/custom_loader.py index a8ca81426..ba6f00ea7 100644 --- a/examples/customize/build_graph/components/loaders/custom_loader.py +++ b/examples/customize/build_graph/components/loaders/custom_loader.py @@ -18,7 +18,6 @@ async def run( text="", document_info=DocumentInfo( path=str(filepath), - # optionally, add some metadata as a dict - metadata=None, + metadata=metadata, ), )