🐶 Dana the Document-Retrieving Dog
▲ Next.js + LangChain.js Retrieval Chain 🦜🔗
- 🔗This template showcases how to perform retrieval with a LangChain.js chain and the Vercel AI SDK in a Next.js project.
- 🪜The chain works in two steps:
- 1️⃣First, it rephrases the input question into a "standalone" question, dereferencing pronouns based on the chat history.
- 2️⃣Then, it queries the retriever for documents similar to the dereferenced question and composes an answer.
- 💻You can find the prompt and model logic for this use-case in
app/api/chat/retrieval/route.ts
. - 🐶By default, the agent is pretending to be a talking puppy, but you can change the prompt to whatever you want!
- 🎨The main frontend logic is found in
app/retrieval/page.tsx
. - 🐙This template is open source - you can see the source code and deploy your own version from the GitHub repo!
- 🔱Before running this example on your own, you'll first need to set up a Supabase vector store. See the README for more details.
- 👇Upload some text, then try asking e.g.
What is a document loader?
below!