diff --git a/llama-index-core/llama_index/core/indices/document_summary/base.py b/llama-index-core/llama_index/core/indices/document_summary/base.py index b9c4d51fbfc818eddbc05686c429111260340080..427192cf6735d81bc3d5b19a54dc7ec45d78f6b2 100644 --- a/llama-index-core/llama_index/core/indices/document_summary/base.py +++ b/llama-index-core/llama_index/core/indices/document_summary/base.py @@ -5,6 +5,7 @@ the summary to the underlying Nodes. This summary can be used for retrieval. """ + import logging from collections import defaultdict from enum import Enum @@ -199,11 +200,13 @@ class DocumentSummaryIndex(BaseIndex[IndexDocumentSummary]): nodes=nodes_with_scores, ) summary_response = cast(Response, summary_response) + metadata = doc_id_to_nodes.get(doc_id, [TextNode()])[0].metadata summary_node_dict[doc_id] = TextNode( text=summary_response.response, relationships={ NodeRelationship.SOURCE: RelatedNodeInfo(node_id=doc_id) }, + metadata=metadata, ) self.docstore.add_documents([summary_node_dict[doc_id]]) logger.info(