Closed bilalshareef closed 7 months ago
Hey @bilalshareef! đ I'm Dosu, your friendly neighborhood bot here to sprinkle some magic on those pesky bugs, answer your burning questions, and help you navigate the path to becoming a contributor. While we wait for a human to chime in, think of me as your go-to for a little extra support. Let's tackle this together! đ¤â¨
Based on your description, it seems like you've identified the issue correctly. The addGraphDocuments
function in the Neo4jGraph
class is indeed trying to set the document text using SET d.text = $document.page_content
, which does not match the property name in your JavaScript objects (pageContent
).
To resolve this issue, you should modify the INCLUDE_DOCS_QUERY
string in the Neo4jGraph
class to use pageContent
instead of page_content
. This change will align the property name in the query with the property name in your JavaScript objects.
Here's the specific change you need to make:
Original line in INCLUDE_DOCS_QUERY
:
SET d.text = $document.page_content
Modified line:
SET d.text = $document.pageContent
After making this change, the INCLUDE_DOCS_QUERY
should look like this:
const INCLUDE_DOCS_QUERY = `
MERGE (d:Document {id:$document.metadata.id})
SET d.text = $document.pageContent
SET d += $document.metadata
WITH d
`;
This modification ensures that when the addGraphDocuments
function is called, the Document
node's text
property is correctly populated with the content from your JavaScript objects' pageContent
property.
Please note that this change should be made in your local copy of the LangChain JS library. If you're using a package manager like npm or yarn, you might need to fork the repository, make the change, and then point your package.json to your forked version.
As for the structure of the GraphDocument
object in the LangChain JS library, it extends the Document
class from @langchain/core/documents
and contains three main properties: nodes
, relationships
, and source
. Each Node
object has properties like id
, type
, properties
, and lc_namespace
. Similarly, each Relationship
object has properties like source
, target
, type
, properties
, and lc_namespace
. The GraphDocument
constructor takes an object with nodes
, relationships
, and source
properties to initialize a new instance.
I hope this helps! If you have any further questions or run into any other issues, feel free to ask.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
I am trying to add Graph documents to Neo4j using langchain library. When I invoked
graph.addGraphDocuments
function, the Document node in Neo4j is not populating the text content for each of the GraphDocument.The issue looks to be in this line where it should read
SET d.text = $document.pageContent
instead ofSET d.text = $document.page_content
.page_content
is valid in python version of the library. But in javascript, it should bepageContent
.System Info
platform - mac Node version - 21.7.1 yarn version - 3.4.1