Skip to content

Commit

Permalink
honor exclusion keys when creating the index nodes (run-llama#14911)
Browse files Browse the repository at this point in the history
* honor exclusion keys when creating the index nodes

* cleaner code based on feedback.

* missed a reference.

* remove unnecessary embedding key removal
  • Loading branch information
ramarnat authored Jul 25, 2024
1 parent 9d1ccdf commit d15f45b
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@ def _add_nodes_to_index(
nodes=nodes_with_scores,
)
summary_response = cast(Response, summary_response)
metadata = doc_id_to_nodes.get(doc_id, [TextNode()])[0].metadata
docid_first_node = doc_id_to_nodes.get(doc_id, [TextNode()])[0]
summary_node_dict[doc_id] = TextNode(
text=summary_response.response,
relationships={
NodeRelationship.SOURCE: RelatedNodeInfo(node_id=doc_id)
},
metadata=metadata,
metadata=docid_first_node.metadata,
excluded_embed_metadata_keys=docid_first_node.excluded_embed_metadata_keys,
excluded_llm_metadata_keys=docid_first_node.excluded_llm_metadata_keys,
)
self.docstore.add_documents([summary_node_dict[doc_id]])
logger.info(
Expand All @@ -227,7 +229,6 @@ def _add_nodes_to_index(
node_with_embedding = node.copy()
node_with_embedding.embedding = id_to_embed_map[node.node_id]
summary_nodes_with_embedding.append(node_with_embedding)

self._vector_store.add(summary_nodes_with_embedding)

def _build_index_from_nodes(
Expand Down

0 comments on commit d15f45b

Please sign in to comment.