Overview
The LangChain + Next.js Starter Template is a scaffolding tool that creates a LangChain.js + Next.js starter app. It demonstrates how to use and combine LangChain modules for various use cases, including simple chat, returning structured output, answering complex multi-step questions with agents, and retrieval augmented generation (RAG) using a chain and vector store or an agent and vector store. The template utilizes Vercel’s AI SDK to stream tokens to the client and display incoming messages.
Features
- Simple Chat: Enables users to have a streaming conversation with the AI.
- Structured Output: Demonstrates how a model can return output according to a specific schema using OpenAI Functions.
- Agents: Allows users to interact with an AI agent by asking more complex questions.
- Retrieval: Uses Supabase as a vector store for retrieval examples. Users can swap in other supported vector stores if preferred.
Installation
- Clone the repo and download it locally.
- Set up environment variables in the
.env.local
file by copying the.env.example
file. - Add your OpenAI API key to the environment variables.
- Install the required packages using your preferred package manager (e.g. yarn).
- Run the development server by opening
http://localhost:3000
in your browser. - Start interacting with the bot by asking it questions.
Summary
The LangChain + Next.js Starter Template is a powerful tool for building language-based applications using LangChain and Next.js. It provides a comprehensive set of features for implementing chat, structured output, agents, and retrieval augmented generation. The template also emphasizes the use of Vercel’s AI SDK for streaming tokens to the client and displaying real-time messages. With its straightforward installation process and flexible customization options, the template is a valuable resource for developers looking to leverage LangChain’s capabilities in their projects.