#ERROR WHILE FOLLOWING THE LANGCHAINJS CHAT BOT PROJECT.

13 messages · Page 1 of 1 (latest)

zealous snow
#

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

GitHub

Contribute to cmm25/chat-bot development by creating an account on GitHub.

stone torrent
#

Hi @zealous snow. Were you able to find an answer to this problem? Look into https://www.npmjs.com/package/read-text-file

stray blade
zealous snow
zealous snow
stray blade
#

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);

zealous snow
#

So what does this achieve

split owl
#

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.

zealous snow
#

actually if you do the initial code .. it runs