Reputation: 460
I am trying to initialize the vector store from the existing graph to perform for vector similarity search. But whatever the value assigned for the "node_label" property wasn't considered.
In the below code example, I assign the "Codeexample" value to the "node_label". However, after the vector store initialization I printed the value of "node_label" and it simply return "Document" every time. This makes my vector similarity search to return empty results.
from neo4j import GraphDatabase
from langchain_openai import OpenAIEmbeddings
from langchain.vectorstores import Neo4jVector
driver = GraphDatabase.driver(url, auth=(username, password))
//Initialize LangChain components
embedding = OpenAIEmbeddings()
vector_store = Neo4jVector.from_existing_graph(
embedding=embedding,
url=url,
username=username,
password=password,
node_label="Codeexample",
text_node_properties=["id", "name", "description", "code"],
embedding_node_property="embedding",
)
//Print Debug Information
print("Node Label:", vector_store.node_label)
----- Node Label: Document ------
//Process natural language query
query = "My code example query"
query_embedding = embedding.embed_query(query)
//Search in the knowledge graph
results = vector_store.similarity_search(query, k=1)
results
Please check this and let me know if I am missing anything here. Thanks in advance :)
Upvotes: 0
Views: 75