Refactor ReadTheDocsLoaderComponent to update document metadata

This commit is contained in:
anovazzi1 2024-01-15 20:06:29 -03:00
commit 184b66f5ab

View file

@ -19,4 +19,11 @@ class ReadTheDocsLoaderComponent(CustomComponent):
path: str,
metadata: Optional[Dict] = None,
) -> List[Document]:
return ReadTheDocsLoader(path=path, metadata=metadata or {}).load()
documents = ReadTheDocsLoader(path=path).load()
if(metadata):
for document in documents:
if not document.metadata:
document.metadata = metadata
else:
document.metadata.update(metadata)
return documents