LangChain Exercises

Fill in the blanks to test your knowledge.

1

Complete the LCEL chain construction using the pipe operator

const chain = prompt model outputParser;
2

Create a ChatPromptTemplate from a template string

const prompt = ChatPromptTemplate.("Tell me about {topic}");
3

Name the output parser that extracts plain text from model output

import { } from "@langchain/core/output_parsers";
const parser = new StringOutputParser();
4

Invoke a chain with variables

const result = await chain.({
topic: "recursion",
language: "Python"
});
5

Name the text splitter that uses multiple separators recursively

const splitter = new CharacterTextSplitter({
chunkSize: 1000,
chunkOverlap: 200
});
6

Get a retriever from a vector store

const retriever = vectorStore.({
k: 4,
searchType: "similarity"
});
7

Name the memory class that stores all conversation messages

import { } from "langchain/memory";
const memory = new BufferMemory();
8

Create a LangChain RAG chain using the retrieval chain factory

const ragChain = await ({
retriever: vectorStore.asRetriever(),
combineDocsChain: documentChain
});