🐛 fix(JSONDocumentBuilder.py): handle both single document and list of documents when building JSON document
✨ feat(JSONDocumentBuilder.py): add support for building JSON document from a list of documents
This commit is contained in:
parent
6e18e795ff
commit
5fa8281e94
1 changed files with 9 additions and 1 deletions
|
|
@ -31,4 +31,12 @@ class JSONDocumentBuilder(CustomComponent):
|
||||||
key: str,
|
key: str,
|
||||||
document: Document,
|
document: Document,
|
||||||
) -> Document:
|
) -> Document:
|
||||||
return Document(page_content={key: document.page_content})
|
documents = None
|
||||||
|
if isinstance(document, list):
|
||||||
|
documents = [
|
||||||
|
Document(page_content={key: doc.page_content}) for doc in document
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
documents = Document(page_content={key: document.page_content})
|
||||||
|
self.repr_value = documents
|
||||||
|
return documents
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue