From 427a04151c96b89b75e93b294cb0eb110d272b02 Mon Sep 17 00:00:00 2001 From: jigsawlabs-student <55858352+jigsawlabs-student@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:01:46 -0400 Subject: [PATCH] community: fix neo4j from_existing_graph (#24912) Fixes Neo4JVector.from_existing_graph integration with huggingface Previously threw an error with existing databases, because from_existing_graph query returns empty list of new nodes, which are then passed to embedding function, and huggingface errors with empty list. Fixes [24401](https://github.com/langchain-ai/langchain/issues/24401) --------- Co-authored-by: Jeff Katzy --- libs/community/langchain_community/vectorstores/neo4j_vector.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/neo4j_vector.py b/libs/community/langchain_community/vectorstores/neo4j_vector.py index e083f3ba3e0..c78c4116112 100644 --- a/libs/community/langchain_community/vectorstores/neo4j_vector.py +++ b/libs/community/langchain_community/vectorstores/neo4j_vector.py @@ -1449,6 +1449,8 @@ class Neo4jVector(VectorStore): "LIMIT 1000" ) data = store.query(fetch_query, params={"props": text_node_properties}) + if not data: + break text_embeddings = embedding.embed_documents([el["text"] for el in data]) params = {