You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following JSON content in a file and would like to use langchain.js and gpt to parse , store and answer question such as
for example:
"find me jobs with 2 year experience" ==> should return a list
"I have knowledge in javascript find me jobs" ==> should return the jobs object
I create a JSON file with 3 object and use the langchain loader to load the file. The file loads but a call to length function returns 13 docs. I only have 3 JSON object in the file.
Can you please show how how to parse the JSON file so I can correctly add to a Vector database to perform query? I would like the matching JSON object to be return for the question.
Here is snippet parse code
const loader = new DirectoryLoader(docPath, {
".json": (path) => new JSONLoader(path),
});
const docs = await loader.load();
console.log(docs);
console.log(docs.length);
Here is my input data
[
{
"jobid":"job1",
"title":"software engineer"
"skills":"java,javascript",
"description":"this job requires a associate degrees in CS and 2 years experience"
},
{
"jobid":"job2",
"skills":"math, accounting, spreadsheet",
"description":"this job requires a degrees in accounting and 2 years experience"
},
{
"jobid":"job3",
"title":"programmer"
"skills":"java,javascript,cloud computing",
"description":"this job requires a ,master degrees in CS and 3 years experience"
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Need some help.
I have the following JSON content in a file and would like to use langchain.js and gpt to parse , store and answer question such as
for example:
"find me jobs with 2 year experience" ==> should return a list
"I have knowledge in javascript find me jobs" ==> should return the jobs object
I create a JSON file with 3 object and use the langchain loader to load the file. The file loads but a call to length function returns 13 docs. I only have 3 JSON object in the file.
Can you please show how how to parse the JSON file so I can correctly add to a Vector database to perform query? I would like the matching JSON object to be return for the question.
Here is snippet parse code
const loader = new DirectoryLoader(docPath, {
".json": (path) => new JSONLoader(path),
});
const docs = await loader.load();
console.log(docs);
console.log(docs.length);
Here is my input data
[
{
"jobid":"job1",
"title":"software engineer"
"skills":"java,javascript",
"description":"this job requires a associate degrees in CS and 2 years experience"
},
{
"jobid":"job2",
"skills":"math, accounting, spreadsheet",
"description":"this job requires a degrees in accounting and 2 years experience"
},
{
"jobid":"job3",
"title":"programmer"
"skills":"java,javascript,cloud computing",
"description":"this job requires a ,master degrees in CS and 3 years experience"
}
]
OUTPUT
[
Document {
pageContent: 'job1',
metadata: {
source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
line: 1
}
},
Document {
pageContent: 'software engineer',
metadata: {
source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
line: 2
}
},
Document {
pageContent: 'java,javascript',
metadata: {
source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
line: 3
}
},
Document {
pageContent: 'this job requires a associate degrees in CS and 2 years experience',
metadata: {
source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
line: 4
}
},
Document {
pageContent: 'job2',
metadata: {
source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
line: 5
}
},
...
.
Beta Was this translation helpful? Give feedback.
All reactions