Skip to content

Commit fc4d87a

Browse files
authored
Fix doc about custom data loader (#436)
* Remove tests on rate limit for SentenceTransformer embedder * Not in this branch
1 parent c766f30 commit fc4d87a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/source/user_guide_kg_builder.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,15 @@ To implement your own loader, use the `DataLoader` interface:
602602
from neo4j_graphrag.experimental.components.pdf_loader import DataLoader, PdfDocument
603603
604604
class MyDataLoader(DataLoader):
605-
async def run(self, path: Path) -> PdfDocument:
606-
# process file in `path`
607-
return PdfDocument(text="text")
605+
async def run(self, filepath: Path, metadata: Optional[Dict[str, str]] = None) -> PdfDocument:
606+
# process file in `filepath`
607+
return PdfDocument(
608+
text="text",
609+
document_info=DocumentInfo(
610+
path=str(filepath),
611+
metadata=metadata,
612+
)
613+
)
608614
609615
610616

examples/customize/build_graph/components/loaders/custom_loader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ async def run(
1818
text="<extracted text>",
1919
document_info=DocumentInfo(
2020
path=str(filepath),
21-
# optionally, add some metadata as a dict
22-
metadata=None,
21+
metadata=metadata,
2322
),
2423
)

0 commit comments

Comments
 (0)