langchain-nextjs-template  by langchain-ai

Next.js template for LangChain apps

created 2 years ago
2,074 stars

Top 22.0% on sourcepulse

GitHubView on GitHub
Project Summary

This template provides a starter application for building AI-powered features using LangChain.js and Next.js. It's designed for developers looking to quickly implement common LLM use cases like chat, structured output, agents, and retrieval-augmented generation (RAG) within a Next.js application, leveraging Vercel's AI SDK for token streaming and LangGraph.js for agentic workflows.

How It Works

The template showcases several LangChain.js patterns, including simple chat with token streaming via Vercel's AI SDK, structured output generation using Zod schemas and OpenAI Functions, and multi-step reasoning with agents built on LangGraph.js. Retrieval Augmented Generation (RAG) examples are demonstrated using Supabase as a vector store, with options to swap for other supported vector stores. LangChain Expression Language (LCEL) is used for composing chains, enabling flexible integration of various LangChain modules.

Quick Start & Requirements

  • Install dependencies: yarn
  • Run development server: yarn dev
  • Requires an OpenAI API key.
  • For agent examples, a SERPAPI_API_KEY is needed.
  • For retrieval examples, Supabase credentials (database URL, private key) are required.
  • Official Docs: https://js.langchain.com/docs/

Highlighted Details

  • Demonstrates RAG with both chains and agents.
  • Utilizes LangGraph.js for building agentic workflows.
  • Includes examples for structured output using Zod and OpenAI Functions.
  • Optimized for Vercel's free tier, with bundle size analysis available via ANALYZE=true yarn build.

Maintenance & Community

  • Project by LangChain AI.
  • Community support available via Discord and Twitter (@LangChainAI).

Licensing & Compatibility

  • MIT License.
  • Compatible with commercial and closed-source applications.

Limitations & Caveats

The retrieval examples use Supabase by default; swapping vector stores requires code modifications in specific API routes. Re-ingesting documents without clearing the vector store can lead to duplicates.

Health Check
Last commit

4 months ago

Responsiveness

1+ week

Pull Requests (30d)
1
Issues (30d)
0
Star History
196 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Didier Lopes Didier Lopes(Founder of OpenBB), and
1 more.

langgraph by langchain-ai

2.1%
17k
Agent orchestration framework for building controllable agents
created 2 years ago
updated 1 day ago
Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Carol Willing Carol Willing(Core Contributor to CPython, Jupyter), and
38 more.

langchain by langchain-ai

0.4%
113k
Framework for building LLM-powered applications
created 2 years ago
updated 1 day ago
Feedback? Help us improve.