44
55from deprecated import deprecated
66from llama_index .core import Document
7- from llama_index .core .node_parser import SimpleNodeParser
7+ from llama_index .core .node_parser import SentenceSplitter
88from llama_index .core .vector_stores import (
99 FilterOperator ,
1010 MetadataFilter ,
@@ -199,7 +199,8 @@ def index(
199199 self .tool .stream_log (f"No nodes found for { doc_id } " )
200200 except Exception as e :
201201 self .tool .stream_log (
202- f"Error querying { vector_db_instance_id } : { e } " , level = LogLevel .ERROR
202+ f"Error querying { vector_db_instance_id } : { e } , proceeding to index" ,
203+ level = LogLevel .ERROR ,
203204 )
204205
205206 if doc_id_found and reindex :
@@ -288,7 +289,7 @@ def index(
288289
289290 try :
290291 if chunk_size == 0 :
291- parser = SimpleNodeParser .from_defaults (
292+ parser = SentenceSplitter .from_defaults (
292293 chunk_size = len (documents [0 ].text ) + 10 ,
293294 chunk_overlap = 0 ,
294295 callback_manager = embedding .get_callback_manager (),
@@ -301,12 +302,6 @@ def index(
301302 vector_db .add (doc_id , nodes = [node ])
302303 self .tool .stream_log ("Added node to vector db" )
303304 else :
304- storage_context = vector_db .get_storage_context ()
305- parser = SimpleNodeParser .from_defaults (
306- chunk_size = chunk_size ,
307- chunk_overlap = chunk_overlap ,
308- callback_manager = embedding .get_callback_manager (),
309- )
310305 self .tool .stream_log ("Adding nodes to vector db..." )
311306 # TODO: Phase 2:
312307 # Post insertion to VDB, use query using doc_id and
@@ -318,13 +313,11 @@ def index(
318313 # Once this is in place, the overridden implementation
319314 # of prefixing ids with doc_id before adding to VDB
320315 # can be removed
321- vector_db .get_vector_store_index_from_storage_context (
316+ vector_db .index_document (
322317 documents ,
323- storage_context = storage_context ,
318+ chunk_size = chunk_size ,
319+ chunk_overlap = chunk_overlap ,
324320 show_progress = True ,
325- embed_model = embedding ,
326- node_parser = parser ,
327- callback_manager = embedding .get_callback_manager (),
328321 )
329322 except Exception as e :
330323 self .tool .stream_log (
0 commit comments