π΄ββ οΈ Chat
𧱠Structured Output
π¦ Agents
πΆ Retrieval
π€ Retrieval Agents
π React Server Components
πΈοΈ LangGraph
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