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 |
|---|---|
|
|
Manages prompt templates and input variables |
|
|
Implements autonomous agents that can use tools and make decisions |
|
|
Combines multiple components into reusable pipelines |
|
|
Core package that exposes many common utilities and functions |
|
|
Community packages |
|
|
Various vector database store integrations |
|
|
Provides abstractions for storing data in memory or in databases |
|
|
Provides helpers for loading documents from various sources |
|
|
Provide LLM integration classes with various providers |
|
|
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


















