From 7acf7f0c8b3655f70e2453eac83aad94c0fa39ff Mon Sep 17 00:00:00 2001 From: Kaan Ozdogan Date: Fri, 1 Mar 2024 22:57:28 +0300 Subject: [PATCH] fixed storage context update & service context issue (#11475) --- .../llama_index/core/indices/knowledge_graph/base.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/llama-index-core/llama_index/core/indices/knowledge_graph/base.py b/llama-index-core/llama_index/core/indices/knowledge_graph/base.py index 86f29a5de8303..b3f9f0013dc3a 100644 --- a/llama-index-core/llama_index/core/indices/knowledge_graph/base.py +++ b/llama-index-core/llama_index/core/indices/knowledge_graph/base.py @@ -259,10 +259,9 @@ def upsert_triplet( self._graph_store.upsert_triplet(*triplet) triplet_str = str(triplet) if include_embeddings: - set_embedding = self._service_context.embed_model.get_text_embedding( - triplet_str - ) + set_embedding = self._embed_model.get_text_embedding(triplet_str) self._index_struct.add_to_embedding_dict(str(triplet), set_embedding) + self._storage_context.index_store.add_index_struct(self._index_struct) def add_node(self, keywords: List[str], node: BaseNode) -> None: """Add node. @@ -300,10 +299,9 @@ def upsert_triplet_and_node( self.add_node([subj, obj], node) triplet_str = str(triplet) if include_embeddings: - set_embedding = self._service_context.embed_model.get_text_embedding( - triplet_str - ) + set_embedding = self._embed_model.get_text_embedding(triplet_str) self._index_struct.add_to_embedding_dict(str(triplet), set_embedding) + self._storage_context.index_store.add_index_struct(self._index_struct) def _delete_node(self, node_id: str, **delete_kwargs: Any) -> None: """Delete a node."""