From b13586cc72b046083cd3dfb2a4017d074dffa63e Mon Sep 17 00:00:00 2001 From: aashish2057 Date: Fri, 3 Nov 2023 18:45:19 -0500 Subject: [PATCH] update langchainjs doc --- docs/tutorials/langchainjs.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/langchainjs.md b/docs/tutorials/langchainjs.md index 076a77ac44..94dc90814f 100644 --- a/docs/tutorials/langchainjs.md +++ b/docs/tutorials/langchainjs.md @@ -23,13 +23,17 @@ const answer = await ollama.call(`why is the sky blue?`); console.log(answer); ``` -That will get us the same thing as if we ran `ollama run llama2 "why is the sky blue"` in the terminal. But we want to load a document from the web to ask a question against. **Cheerio** is a great library for ingesting a webpage, and **LangChain** uses it in their **CheerioWebBaseLoader**. So let's build that part of the app. +That will get us the same thing as if we ran `ollama run llama2 "why is the sky blue"` in the terminal. But we want to load a document from the web to ask a question against. **Cheerio** is a great library for ingesting a webpage, and **LangChain** uses it in their **CheerioWebBaseLoader**. So let's install **Cheerio** and build that part of the app. + +```bash +npm install cheerio +``` ```javascript import { CheerioWebBaseLoader } from "langchain/document_loaders/web/cheerio"; const loader = new CheerioWebBaseLoader("https://en.wikipedia.org/wiki/2023_Hawaii_wildfires"); -const data = loader.load(); +const data = await loader.load(); ``` That will load the document. Although this page is smaller than the Odyssey, it is certainly bigger than the context size for most LLMs. So we are going to need to split into smaller pieces, and then select just the pieces relevant to our question. This is a great use for a vector datastore. In this example, we will use the **MemoryVectorStore** that is part of **LangChain**. But there is one more thing we need to get the content into the datastore. We have to run an embeddings process that converts the tokens in the text into a series of vectors. And for that, we are going to use **Tensorflow**. There is a lot of stuff going on in this one. First, install the **Tensorflow** components that we need.