Skip to content

Commit 4c7821e

Browse files
created neo4j from existing index
1 parent 62f454d commit 4c7821e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

backend/src/QA_integration.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,26 @@ def initialize_neo4j_vector(graph, chat_mode_settings):
288288
)
289289
logging.info(f"Successfully retrieved Neo4jVector Fulltext index '{index_name}' and keyword index '{keyword_index}'")
290290
else:
291-
neo_db = Neo4jVector.from_existing_index(
291+
# neo_db = Neo4jVector.from_existing_index(
292+
# embedding=EMBEDDING_FUNCTION,
293+
# index_name=index_name,
294+
# retrieval_query=retrieval_query,
295+
# graph=graph
296+
# )
297+
neo_db = Neo4jVector.from_existing_graph(
292298
embedding=EMBEDDING_FUNCTION,
293299
index_name=index_name,
294300
retrieval_query=retrieval_query,
295-
graph=graph
301+
graph=graph,
302+
node_label="Chunk",
303+
embedding_node_property="embedding",
304+
text_node_properties=["text"]
296305
)
297306

298307
logging.info(f"Successfully retrieved Neo4jVector index '{index_name}'")
299308
except Exception as e:
300-
logging.error(f"Error retrieving Neo4jVector index : {e}")
309+
index_name = chat_mode_settings.get("index_name")
310+
logging.error(f"Error retrieving Neo4jVector index {index_name} : {e}")
301311
raise
302312
return neo_db
303313

@@ -329,8 +339,9 @@ def get_neo4j_retriever(graph, document_names,chat_mode_settings, search_k=CHAT_
329339
retriever = create_retriever(neo_db, document_names,chat_mode_settings, search_k, score_threshold)
330340
return retriever
331341
except Exception as e:
332-
logging.error(f"Error retrieving Neo4jVector index or creating retriever: {e}")
333-
raise Exception("An error occurred while retrieving the Neo4jVector index or creating the retriever. Please drop and create a new vector index: {e}") from e
342+
index_name = chat_mode_settings.get("index_name")
343+
logging.error(f"Error retrieving Neo4jVector index {index_name} or creating retriever: {e}")
344+
raise Exception(f"An error occurred while retrieving the Neo4jVector index or creating the retriever. Please drop and create a new vector index '{index_name}': {e}") from e
334345

335346

336347
def setup_chat(model, graph, document_names, chat_mode_settings):

0 commit comments

Comments
 (0)