I recently began the chatbot course using langchain.js. I am encountering errors to be specific langchain libraries not being recognized and url parse errors while i run my index.js. I am correctly installed the Lang chain library as shared in their documentation. To be specific on where I am at the course … i have just completed video 7. I am sharing the repo where my project is for review https://github.com/cmm25/chat-bot
#ERROR WHILE FOLLOWING THE LANGCHAINJS CHAT BOT PROJECT.
13 messages · Page 1 of 1 (latest)
Hi @zealous snow. Were you able to find an answer to this problem? Look into https://www.npmjs.com/package/read-text-file
Hi there I am doing the same course right now and the problem you're having is that you need to use the text loader
https://js.langchain.com/docs/modules/data_connection/document_loaders/
Hi Aaron could you please explain
Hi David. Let me look into it and get back to you
Basically instead of how they load the text file in the scrimba course you can do it like this
try{
// const loader = new TextLoader("scrimba-info.txt");
// const text = await loader.load();
// const splitter = new RecursiveCharacterTextSplitter({
// chunkSize: 500,
// separators: ['\n\n', '\n', ' ', ''],
// chunkOverlap: 50
// });
// const output = await splitter.splitDocuments(text);
So what does this achieve
Thanks @stray blade - that worked for me!
`import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
try {
const loader = new TextLoader("scrimba-info.txt");
const text = await loader.load();
// const result = await fetch('scrimba-info.txt')
// const text = await result.text()
const splitter = new RecursiveCharacterTextSplitter({
chunkSize: 500,
separators: ["\n\n", "\n", " ", ""], // default setting
chunkOverlap: 50,
});
const output = await splitter.createDocuments([text]);
console.log(output);
} catch (err) {
console.log(err);
}
`
@zealous snow were you able to get it to work? I had to modify output variable as well. I pasted my code above.
yep no problem
actually if you do the initial code .. it runs