liveBook · Manning

LangChain

As explained in Build AI-Enhanced Web Apps

LangChain is a software framework, including its JavaScript implementation, for composing applications that use language models, tools, retrieval, and multi-step chains.

LangChain is a framework for composing language models, APIs, retrieval, and other tools into multistep workflows. Its JavaScript implementation, LangChain.js, provides a composable API for managing model calls, transforming outputs, and connecting to data stores. A chain links operations so an application can do more than send one prompt and display one response. section 6.1 section 6.0

Table 6.1 The main modules available from the LangChain.js library

Module

Description

langchain/prompts

Manages prompt templates and input variables

langchain/agents

Implements autonomous agents that can use tools and make decisions

langchain/chains

Combines multiple components into reusable pipelines

@langchain/core

Core package that exposes many common utilities and functions

@langchain/community

Community packages

langchain/vectorstores

Various vector database store integrations

langchain/storage

Provides abstractions for storing data in memory or in databases

langchain/document_loaders

Provides helpers for loading documents from various sources

@langchain/openai, @langchain/anthropic

Provide LLM integration classes with various providers

langchain/output_parsers

Exposes classes that transform outputs from LLMs into a more suitable format

The module table is a map of the available building blocks: prompts, chains, agents, document loaders, vector stores, model integrations, and output parsers. section 6.1

Choose components according to the job:

  • Use prompt templates to format inputs consistently; use runnables and chains to connect processing steps and parse the result. section 6.1.2 section 6.6
  • Use document loaders, splitting, and retrieval to supply relevant context to summarization or retrieval-augmented generation (RAG). section 7.1.3 section 7.2.1
  • Use conversation memory for previous messages, or agents when a model must decide which external tools to call. section 6.3 section 6.4

Stream a composed response into a web UI

A JavaScript chain can pipe a weather-data function through a prompt template, model, and StringOutputParser, then call chain.stream({ city }). A Next.js server action can consume the returned chunks and update a Vercel AI SDK createStreamableUI instance as text arrives. This separates workflow orchestration from UI streaming. section 6.1.2

For document summarization, PDFLoader or DocxLoader parses an upload into documents; RecursiveCharacterTextSplitter prepares chunks; a map-reduce summarization chain combines chunk summaries. For RAG, LangChain.js handles document processing, retrieval, and prompt augmentation while Next.js and the Vercel AI SDK handle the interface and streamed responses. Model access requires the appropriate provider API key. section 7.1.3 section 7.2.1 section 7.2.3

The abstraction does not remove application responsibilities. Store conversation sessions in a suitable data store, test chains and retrieval with fake models or retrievers, and debug chain execution separately from model integration. LangChain.js runs in JavaScript or TypeScript without requiring Python for its core library; particular community integrations may have additional dependencies. section 6.3 section 8.4.4 section 8.3

How Build AI-Enhanced Web Apps covers it

How deep it goes
Works through modules, composed chains, memory, document pipelines, testing, and integrations without surveying the entire ecosystem.
Examples
Uses a streaming weather chain, PDF and DOCX summarization, RAG applications, and fake-model tests.
What it assumes
Assumes JavaScript web-development context while introducing LangChain’s chains and modules; model-backed examples require provider API keys.
What you can do after
Build it from scratch: compose LangChain.js workflows for chat, summarization, and retrieval, then integrate them with a web UI.
How it connects
Connects prompt templates, runnables, agents, conversation memory, RAG, Next.js, and the Vercel AI SDK.

Also explained in

Compare how 19 books explain LangChain →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI-Enhanced Web Apps. The section links point to the parts of the book it draws on.