🏴☠️ Chat
🧱 Structured Output
🦜 Agents
🐶 Retrieval
🤖 Retrieval Agents
🌊 LangChain x AI SDK RSC
Open in GitHub
▲
+
🦜🔗
🔗
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
.
🔱
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!
Upload document
Send