A params object containing a retriever and a combineDocsChain.
An LCEL Runnable which returns a an object
containing at least context
and answer
keys.
// yarn add langchain @langchain/openai
import { ChatOpenAI } from "@langchain/openai";
import { pull } from "langchain/hub";
import { createRetrievalChain } from "langchain/chains/retrieval";
import { createStuffDocumentsChain } from "langchain/chains/combine_documents";
const retrievalQAChatPrompt = await pull("langchain-ai/retrieval-qa-chat");
const llm = new ChatOpenAI({});
const retriever = ...
const combineDocsChain = await createStuffDocumentsChain(...);
const retrievalChain = await createRetrievalChain({
retriever,
combineDocsChain,
});
const response = await chain.invoke({ input: "..." });
Create a retrieval chain that retrieves documents and then passes them on.