langchain 1.0.0-alpha.9 β 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +260 -0
- package/README.md +29 -77
- package/dist/agents/ReactAgent.cjs +6 -5
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +11 -11
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +11 -11
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +6 -5
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/annotation.cjs +8 -9
- package/dist/agents/annotation.cjs.map +1 -1
- package/dist/agents/annotation.js +8 -9
- package/dist/agents/annotation.js.map +1 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +23 -23
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +23 -23
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/middleware/callLimit.cjs +29 -27
- package/dist/agents/middleware/callLimit.cjs.map +1 -1
- package/dist/agents/middleware/callLimit.d.cts.map +1 -1
- package/dist/agents/middleware/callLimit.d.ts.map +1 -1
- package/dist/agents/middleware/callLimit.js +29 -27
- package/dist/agents/middleware/callLimit.js.map +1 -1
- package/dist/agents/middleware/contextEditing.cjs +1 -1
- package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
- package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
- package/dist/agents/middleware/contextEditing.js +1 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
- package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
- package/dist/agents/middleware/hitl.cjs +92 -90
- package/dist/agents/middleware/hitl.cjs.map +1 -1
- package/dist/agents/middleware/hitl.d.cts +20 -20
- package/dist/agents/middleware/hitl.d.cts.map +1 -1
- package/dist/agents/middleware/hitl.d.ts +20 -20
- package/dist/agents/middleware/hitl.d.ts.map +1 -1
- package/dist/agents/middleware/hitl.js +92 -90
- package/dist/agents/middleware/hitl.js.map +1 -1
- package/dist/agents/middleware/modelFallback.cjs +1 -1
- package/dist/agents/middleware/modelFallback.cjs.map +1 -1
- package/dist/agents/middleware/modelFallback.d.cts +1 -1
- package/dist/agents/middleware/modelFallback.d.cts.map +1 -1
- package/dist/agents/middleware/modelFallback.d.ts +1 -1
- package/dist/agents/middleware/modelFallback.d.ts.map +1 -1
- package/dist/agents/middleware/modelFallback.js +1 -1
- package/dist/agents/middleware/modelFallback.js.map +1 -1
- package/dist/agents/middleware/promptCaching.d.cts.map +1 -1
- package/dist/agents/middleware/promptCaching.d.ts.map +1 -1
- package/dist/agents/middleware/summarization.cjs +1 -1
- package/dist/agents/middleware/summarization.js +1 -1
- package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
- package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
- package/dist/agents/middleware/toolCallLimit.cjs +30 -28
- package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
- package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
- package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
- package/dist/agents/middleware/toolCallLimit.js +30 -28
- package/dist/agents/middleware/toolCallLimit.js.map +1 -1
- package/dist/agents/middleware/types.d.cts +165 -19
- package/dist/agents/middleware/types.d.cts.map +1 -1
- package/dist/agents/middleware/types.d.ts +165 -19
- package/dist/agents/middleware/types.d.ts.map +1 -1
- package/dist/agents/middleware/utils.cjs +10 -0
- package/dist/agents/middleware/utils.cjs.map +1 -1
- package/dist/agents/middleware/utils.d.cts.map +1 -1
- package/dist/agents/middleware/utils.d.ts.map +1 -1
- package/dist/agents/middleware/utils.js +9 -1
- package/dist/agents/middleware/utils.js.map +1 -1
- package/dist/agents/middleware.cjs +6 -10
- package/dist/agents/middleware.cjs.map +1 -1
- package/dist/agents/middleware.d.cts +12 -32
- package/dist/agents/middleware.d.cts.map +1 -1
- package/dist/agents/middleware.d.ts +12 -32
- package/dist/agents/middleware.d.ts.map +1 -1
- package/dist/agents/middleware.js +6 -10
- package/dist/agents/middleware.js.map +1 -1
- package/dist/agents/nodes/AfterAgentNode.cjs +3 -1
- package/dist/agents/nodes/AfterAgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AfterAgentNode.js +3 -1
- package/dist/agents/nodes/AfterAgentNode.js.map +1 -1
- package/dist/agents/nodes/AfterModelNode.cjs +3 -1
- package/dist/agents/nodes/AfterModelNode.cjs.map +1 -1
- package/dist/agents/nodes/AfterModelNode.js +3 -1
- package/dist/agents/nodes/AfterModelNode.js.map +1 -1
- package/dist/agents/nodes/AgentNode.cjs +1 -0
- package/dist/agents/nodes/AgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AgentNode.js +1 -0
- package/dist/agents/nodes/AgentNode.js.map +1 -1
- package/dist/agents/nodes/BeforeAgentNode.cjs +3 -1
- package/dist/agents/nodes/BeforeAgentNode.cjs.map +1 -1
- package/dist/agents/nodes/BeforeAgentNode.js +3 -1
- package/dist/agents/nodes/BeforeAgentNode.js.map +1 -1
- package/dist/agents/nodes/BeforeModelNode.cjs +3 -1
- package/dist/agents/nodes/BeforeModelNode.cjs.map +1 -1
- package/dist/agents/nodes/BeforeModelNode.js +3 -1
- package/dist/agents/nodes/BeforeModelNode.js.map +1 -1
- package/dist/agents/nodes/ToolNode.cjs +37 -36
- package/dist/agents/nodes/ToolNode.cjs.map +1 -1
- package/dist/agents/nodes/ToolNode.js +37 -36
- package/dist/agents/nodes/ToolNode.js.map +1 -1
- package/dist/agents/nodes/middleware.cjs +10 -9
- package/dist/agents/nodes/middleware.cjs.map +1 -1
- package/dist/agents/nodes/middleware.js +10 -9
- package/dist/agents/nodes/middleware.js.map +1 -1
- package/dist/agents/nodes/types.d.cts +15 -0
- package/dist/agents/nodes/types.d.cts.map +1 -1
- package/dist/agents/nodes/types.d.ts +15 -0
- package/dist/agents/nodes/types.d.ts.map +1 -1
- package/dist/agents/types.d.cts +48 -3
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +48 -3
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/utils.cjs +4 -4
- package/dist/agents/utils.cjs.map +1 -1
- package/dist/agents/utils.js +4 -4
- package/dist/agents/utils.js.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/load/import_map.cjs +1 -5
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +1 -5
- package/dist/load/import_map.js.map +1 -1
- package/package.json +30 -49
- package/dist/embeddings/cache_backed.cjs +0 -140
- package/dist/embeddings/cache_backed.cjs.map +0 -1
- package/dist/embeddings/cache_backed.d.cts +0 -107
- package/dist/embeddings/cache_backed.d.cts.map +0 -1
- package/dist/embeddings/cache_backed.d.ts +0 -107
- package/dist/embeddings/cache_backed.d.ts.map +0 -1
- package/dist/embeddings/cache_backed.js +0 -134
- package/dist/embeddings/cache_backed.js.map +0 -1
- package/dist/embeddings/fake.cjs +0 -22
- package/dist/embeddings/fake.cjs.map +0 -1
- package/dist/embeddings/fake.d.cts +0 -1
- package/dist/embeddings/fake.d.ts +0 -1
- package/dist/embeddings/fake.js +0 -12
- package/dist/embeddings/fake.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# langchain
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
π **LangChain v1.0** is here! This release provides a focused, production-ready foundation for building agents. We've streamlined the framework around three core improvements: **`createAgent`**, **standard content blocks**, and a **simplified package structure**. See the [release notes](https://docs.langchain.com/oss/javascript/releases/langchain-v1) for complete details.
|
|
6
|
+
|
|
7
|
+
### β¨ Major Features
|
|
8
|
+
|
|
9
|
+
#### `createAgent` - A new standard for building agents
|
|
10
|
+
|
|
11
|
+
`createAgent` is the new standard way to build agents in LangChain 1.0. It provides a simpler interface than `createReactAgent` from LangGraph while offering greater customization potential through middleware.
|
|
12
|
+
|
|
13
|
+
**Key features:**
|
|
14
|
+
|
|
15
|
+
- **Clean, intuitive API**: Build agents with minimal boilerplate
|
|
16
|
+
- **Built on LangGraph**: Get persistence, streaming, human-in-the-loop, and time travel out of the box
|
|
17
|
+
- **Middleware-first design**: Highly customizable through composable middleware
|
|
18
|
+
- **Improved structured output**: Generate structured outputs in the main agent loop without additional LLM calls
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createAgent } from "langchain";
|
|
24
|
+
|
|
25
|
+
const agent = createAgent({
|
|
26
|
+
model: "anthropic:claude-sonnet-4-5-20250929",
|
|
27
|
+
tools: [getWeather],
|
|
28
|
+
systemPrompt: "You are a helpful assistant.",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const result = await agent.invoke({
|
|
32
|
+
messages: [{ role: "user", content: "What is the weather in Tokyo?" }],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log(result.content);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Under the hood, `createAgent` is built on the basic agent loopβcalling a model using LangGraph, letting it choose tools to execute, and then finishing when it calls no more tools.
|
|
39
|
+
|
|
40
|
+
**Built on LangGraph features (work out of the box):**
|
|
41
|
+
|
|
42
|
+
- **Persistence**: Conversations automatically persist across sessions with built-in checkpointing
|
|
43
|
+
- **Streaming**: Stream tokens, tool calls, and reasoning traces in real-time
|
|
44
|
+
- **Human-in-the-loop**: Pause agent execution for human approval before sensitive actions
|
|
45
|
+
- **Time travel**: Rewind conversations to any point and explore alternate paths
|
|
46
|
+
|
|
47
|
+
**Structured output improvements:**
|
|
48
|
+
|
|
49
|
+
- Generate structured outputs in the main loop instead of requiring an additional LLM call
|
|
50
|
+
- Models can choose between calling tools or using provider-side structured output generation
|
|
51
|
+
- Significant cost reduction by eliminating extra LLM calls
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { createAgent } from "langchain";
|
|
57
|
+
import * as z from "zod";
|
|
58
|
+
|
|
59
|
+
const weatherSchema = z.object({
|
|
60
|
+
temperature: z.number(),
|
|
61
|
+
condition: z.string(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const agent = createAgent({
|
|
65
|
+
model: "openai:gpt-4o-mini",
|
|
66
|
+
tools: [getWeather],
|
|
67
|
+
responseFormat: weatherSchema,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = await agent.invoke({
|
|
71
|
+
messages: [{ role: "user", content: "What is the weather in Tokyo?" }],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(result.structuredResponse);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For more information, see [Agents documentation](https://docs.langchain.com/oss/javascript/langchain/agents).
|
|
78
|
+
|
|
79
|
+
#### Middleware
|
|
80
|
+
|
|
81
|
+
Middleware is what makes `createAgent` highly customizable, raising the ceiling for what you can build. Great agents require **context engineering**βgetting the right information to the model at the right time. Middleware helps you control dynamic prompts, conversation summarization, selective tool access, state management, and guardrails through a composable abstraction.
|
|
82
|
+
|
|
83
|
+
**Prebuilt middleware** for common patterns:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import {
|
|
87
|
+
createAgent,
|
|
88
|
+
summarizationMiddleware,
|
|
89
|
+
humanInTheLoopMiddleware,
|
|
90
|
+
piiRedactionMiddleware,
|
|
91
|
+
} from "langchain";
|
|
92
|
+
|
|
93
|
+
const agent = createAgent({
|
|
94
|
+
model: "anthropic:claude-sonnet-4-5-20250929",
|
|
95
|
+
tools: [readEmail, sendEmail],
|
|
96
|
+
middleware: [
|
|
97
|
+
piiRedactionMiddleware({ patterns: ["email", "phone", "ssn"] }),
|
|
98
|
+
summarizationMiddleware({
|
|
99
|
+
model: "anthropic:claude-sonnet-4-5-20250929",
|
|
100
|
+
maxTokensBeforeSummary: 500,
|
|
101
|
+
}),
|
|
102
|
+
humanInTheLoopMiddleware({
|
|
103
|
+
interruptOn: {
|
|
104
|
+
sendEmail: {
|
|
105
|
+
allowedDecisions: ["approve", "edit", "reject"],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
] as const,
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Custom middleware** with lifecycle hooks:
|
|
114
|
+
|
|
115
|
+
| Hook | When it runs | Use cases |
|
|
116
|
+
| --------------- | ------------------------ | --------------------------------------- |
|
|
117
|
+
| `beforeAgent` | Before calling the agent | Load memory, validate input |
|
|
118
|
+
| `beforeModel` | Before each LLM call | Update prompts, trim messages |
|
|
119
|
+
| `wrapModelCall` | Around each LLM call | Intercept and modify requests/responses |
|
|
120
|
+
| `wrapToolCall` | Around each tool call | Intercept and modify tool execution |
|
|
121
|
+
| `afterModel` | After each LLM response | Validate output, apply guardrails |
|
|
122
|
+
| `afterAgent` | After agent completes | Save results, cleanup |
|
|
123
|
+
|
|
124
|
+
Example custom middleware:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { createMiddleware } from "langchain";
|
|
128
|
+
|
|
129
|
+
const contextSchema = z.object({
|
|
130
|
+
userExpertise: z.enum(["beginner", "expert"]).default("beginner"),
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const expertiseBasedToolMiddleware = createMiddleware({
|
|
134
|
+
wrapModelCall: async (request, handler) => {
|
|
135
|
+
const userLevel = request.runtime.context.userExpertise;
|
|
136
|
+
if (userLevel === "expert") {
|
|
137
|
+
const tools = [advancedSearch, dataAnalysis];
|
|
138
|
+
return handler(request.replace("openai:gpt-5", tools));
|
|
139
|
+
}
|
|
140
|
+
const tools = [simpleSearch, basicCalculator];
|
|
141
|
+
return handler(request.replace("openai:gpt-5-nano", tools));
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const agent = createAgent({
|
|
146
|
+
model: "anthropic:claude-sonnet-4-5-20250929",
|
|
147
|
+
tools: [simpleSearch, advancedSearch, basicCalculator, dataAnalysis],
|
|
148
|
+
middleware: [expertiseBasedToolMiddleware],
|
|
149
|
+
contextSchema,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
For more information, see the [complete middleware guide](https://docs.langchain.com/oss/javascript/langchain/middleware).
|
|
154
|
+
|
|
155
|
+
#### Simplified Package
|
|
156
|
+
|
|
157
|
+
LangChain v1 streamlines the `langchain` package namespace to focus on essential building blocks for agents. The package exposes only the most useful and relevant functionality (most re-exported from `@langchain/core` for convenience).
|
|
158
|
+
|
|
159
|
+
**What's in the core `langchain` package:**
|
|
160
|
+
|
|
161
|
+
- `createAgent` and agent-related utilities
|
|
162
|
+
- Core message types and content blocks
|
|
163
|
+
- Middleware infrastructure
|
|
164
|
+
- Tool definitions and schemas
|
|
165
|
+
- Prompt templates
|
|
166
|
+
- Output parsers
|
|
167
|
+
- Base runnable abstractions
|
|
168
|
+
|
|
169
|
+
### π Migration Notes
|
|
170
|
+
|
|
171
|
+
#### `@langchain/classic` for Legacy Functionality
|
|
172
|
+
|
|
173
|
+
Legacy functionality has moved to [`@langchain/classic`](https://www.npmjs.com/package/@langchain/classic) to keep the core package lean and focused.
|
|
174
|
+
|
|
175
|
+
**What's in `@langchain/classic`:**
|
|
176
|
+
|
|
177
|
+
- Legacy chains and chain implementations
|
|
178
|
+
- The indexing API
|
|
179
|
+
- [`@langchain/community`](https://www.npmjs.com/package/@langchain/community) exports
|
|
180
|
+
- Other deprecated functionality
|
|
181
|
+
|
|
182
|
+
**To migrate legacy code:**
|
|
183
|
+
|
|
184
|
+
1. Install `@langchain/classic`:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm install @langchain/classic
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
2. Update your imports:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { ... } from "langchain"; // [!code --]
|
|
194
|
+
import { ... } from "@langchain/classic"; // [!code ++]
|
|
195
|
+
|
|
196
|
+
import { ... } from "langchain/chains"; // [!code --]
|
|
197
|
+
import { ... } from "@langchain/classic/chains"; // [!code ++]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Upgrading to v1
|
|
201
|
+
|
|
202
|
+
Install the v1 packages:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npm install langchain@1.0.0 @langchain/core@1.0.0
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### π Additional Resources
|
|
209
|
+
|
|
210
|
+
- [LangChain 1.0 Announcement](https://blog.langchain.com/langchain-langchain-1-0-alpha-releases/)
|
|
211
|
+
- [Migration Guide](https://docs.langchain.com/oss/javascript/migrate/langchain-v1)
|
|
212
|
+
- [Agents Documentation](https://docs.langchain.com/oss/javascript/langchain/agents)
|
|
213
|
+
- [Middleware Guide](https://blog.langchain.com/agent-middleware/)
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 0.3.36
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- cabd762: fix(langchain): add ChatMistralAI to well known models
|
|
222
|
+
- Updated dependencies [e63c7cc]
|
|
223
|
+
- Updated dependencies [b8ffc1e]
|
|
224
|
+
- @langchain/openai@0.6.16
|
|
225
|
+
|
|
226
|
+
## 0.3.35
|
|
227
|
+
|
|
228
|
+
### Patch Changes
|
|
229
|
+
|
|
230
|
+
- fd4691f: use `keyEncoder` instead of insecure cache key getter
|
|
231
|
+
- 2f19cd5: feat: Add Perplexity support to universal chat model
|
|
232
|
+
- 3c94076: fix(langchain): Bind schemas for other types of pulled hub prompts
|
|
233
|
+
- Updated dependencies [d38e9d6]
|
|
234
|
+
- @langchain/openai@0.6.14
|
|
235
|
+
|
|
236
|
+
## 0.3.34
|
|
237
|
+
|
|
238
|
+
### Patch Changes
|
|
239
|
+
|
|
240
|
+
- 6019a7d: update JSONL loader to support complex json structures
|
|
241
|
+
- caf5579: prevent ConfigurableModel mutation when using withStructuredOutput or bindTools
|
|
242
|
+
- d60f40f: infer mistralai models
|
|
243
|
+
- Updated dependencies [41bd944]
|
|
244
|
+
- Updated dependencies [707a768]
|
|
245
|
+
- @langchain/openai@0.6.12
|
|
246
|
+
|
|
247
|
+
## 0.3.33
|
|
248
|
+
|
|
249
|
+
### Patch Changes
|
|
250
|
+
|
|
251
|
+
- d2c7f09: support prompts not created from RunnableBinding
|
|
252
|
+
|
|
253
|
+
## 0.3.32
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- e0bd88c: add support for conversion of ref in array schema
|
|
258
|
+
- Updated dependencies [4a3f5af]
|
|
259
|
+
- Updated dependencies [424360b]
|
|
260
|
+
- @langchain/openai@0.6.10
|
package/README.md
CHANGED
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
# π¦οΈπ LangChain.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 [](https://opensource.org/licenses/MIT) [](https://twitter.com/langchainai)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[<img src="https://github.com/codespaces/badge.svg" title="Open in Github Codespace" width="150" height="20">](https://codespaces.new/langchain-ai/langchainjs)
|
|
5
|
+
LangChain is a framework for building LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development β all while future-proofing decisions as the underlying technology evolves.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
**Documentation**: To learn more about LangChain, check out [the docs](https://docs.langchain.com/oss/javascript/langchain/overview).
|
|
8
|
+
|
|
9
|
+
If you're looking for more advanced customization or agent orchestration, check out [LangGraph.js](https://langchain-ai.github.io/langgraphjs/). our framework for building agents and controllable workflows.
|
|
10
|
+
|
|
11
|
+
> [!NOTE]
|
|
12
|
+
> Looking for the Python version? Check out [LangChain](https://github.com/langchain-ai/langchain).
|
|
9
13
|
|
|
10
14
|
To help you ship LangChain apps to production faster, check out [LangSmith](https://smith.langchain.com).
|
|
11
15
|
[LangSmith](https://smith.langchain.com) is a unified developer platform for building, testing, and monitoring LLM applications.
|
|
12
16
|
|
|
13
17
|
## β‘οΈ Quick Install
|
|
14
18
|
|
|
15
|
-
You can use npm,
|
|
19
|
+
You can use npm, pnpm, or yarn to install LangChain.js
|
|
20
|
+
|
|
21
|
+
`npm install -S langchain` or `pnpm install langchain` or `yarn add langchain`
|
|
22
|
+
|
|
23
|
+
## π Why use LangChain?
|
|
24
|
+
|
|
25
|
+
LangChain helps developers build applications powered by LLMs through a standard interface for agents, models, embeddings, vector stores, and more.
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
Use LangChain for:
|
|
28
|
+
|
|
29
|
+
- **Real-time data augmentation**. Easily connect LLMs to diverse data sources and external/internal systems, drawing from LangChainβs vast library of integrations with model providers, tools, vector stores, retrievers, and more.
|
|
30
|
+
- **Model interoperability**. Swap models in and out as your engineering team experiments to find the best choice for your applicationβs needs. As the industry frontier evolves, adapt quickly β LangChainβs abstractions keep you moving without losing momentum.
|
|
31
|
+
|
|
32
|
+
## π¦ LangChain's ecosystem
|
|
33
|
+
|
|
34
|
+
- [LangSmith](https://www.langchain.com/langsmith) - Unified developer platform for building, testing, and monitoring LLM applications. With LangSmith, you can debug poor-performing LLM app runs, evaluate agent trajectories, gain visibility in production, and deploy agents with confidence.
|
|
35
|
+
- [LangGraph](https://docs.langchain.com/oss/javascript/langgraph/overview) - Build agents that can reliably handle complex tasks with LangGraph, our low-level agent orchestration framework. LangGraph offers customizable architecture, long-term memory, and human-in-the-loop workflows β and is trusted in production by companies like LinkedIn, Uber, Klarna, and GitLab.
|
|
18
36
|
|
|
19
37
|
## π Supported Environments
|
|
20
38
|
|
|
21
|
-
LangChain is written in TypeScript and can be used in:
|
|
39
|
+
LangChain.js is written in TypeScript and can be used in:
|
|
22
40
|
|
|
23
41
|
- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x, 22.x
|
|
24
42
|
- Cloudflare Workers
|
|
@@ -27,74 +45,12 @@ LangChain is written in TypeScript and can be used in:
|
|
|
27
45
|
- Browser
|
|
28
46
|
- Deno
|
|
29
47
|
|
|
30
|
-
## π€ What is LangChain?
|
|
31
|
-
|
|
32
|
-
**LangChain** is a framework for developing applications powered by language models. It enables applications that:
|
|
33
|
-
|
|
34
|
-
- **Are context-aware**: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.)
|
|
35
|
-
- **Reason**: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.)
|
|
36
|
-
|
|
37
|
-
This framework consists of several parts.
|
|
38
|
-
|
|
39
|
-
- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/docs/concepts/lcel), [components](https://js.langchain.com/docs/concepts), and [third-party integrations](https://js.langchain.com/docs/integrations/platforms/).
|
|
40
|
-
Use [LangGraph.js](https://js.langchain.com/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support.
|
|
41
|
-
- **Productionization**: Use [LangSmith](https://docs.smith.langchain.com/) to inspect, monitor and evaluate your chains, so that you can continuously optimize and deploy with confidence.
|
|
42
|
-
- **Deployment**: Turn your LangGraph applications into production-ready APIs and Assistants with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/).
|
|
43
|
-
|
|
44
|
-
The LangChain libraries themselves are made up of several different packages.
|
|
45
|
-
|
|
46
|
-
- **[`@langchain/core`](https://github.com/langchain-ai/langchainjs/blob/main/langchain-core)**: Base abstractions and LangChain Expression Language.
|
|
47
|
-
- **[`@langchain/community`](https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community)**: Third party integrations.
|
|
48
|
-
- **[`langchain`](https://github.com/langchain-ai/langchainjs/blob/main/langchain)**: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.
|
|
49
|
-
- **[LangGraph.js](https://langchain-ai.github.io/langgraphjs/)**: LangGraph powers production-grade agents, trusted by Linkedin, Uber, Klarna, GitLab, and many more. Build robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. Integrates smoothly with LangChain, but can be used without it.
|
|
50
|
-
|
|
51
|
-
Integrations may also be split into their own compatible packages.
|
|
52
|
-
|
|
53
|
-

|
|
54
|
-
|
|
55
|
-
This library aims to assist in the development of those types of applications. Common examples of these applications include:
|
|
56
|
-
|
|
57
|
-
**βQuestion Answering over specific documents**
|
|
58
|
-
|
|
59
|
-
- [Documentation](https://js.langchain.com/docs/tutorials/rag/)
|
|
60
|
-
- End-to-end Example: [Doc-Chatbot](https://github.com/dissorial/doc-chatbot)
|
|
61
|
-
|
|
62
|
-
**π¬ Chatbots**
|
|
63
|
-
|
|
64
|
-
- [Documentation](https://js.langchain.com/docs/tutorials/chatbot)
|
|
65
|
-
- End-to-end Example: [Chat-LangChain](https://github.com/langchain-ai/chat-langchain)
|
|
66
|
-
|
|
67
|
-
## π How does LangChain help?
|
|
68
|
-
|
|
69
|
-
The main value props of the LangChain libraries are:
|
|
70
|
-
|
|
71
|
-
1. **Components**: composable tools and integrations for working with language models. Components are modular and easy-to-use, whether you are using the rest of the LangChain framework or not
|
|
72
|
-
2. **Off-the-shelf chains**: built-in assemblages of components for accomplishing higher-level tasks
|
|
73
|
-
|
|
74
|
-
Off-the-shelf chains make it easy to get started. Components make it easy to customize existing chains and build new ones.
|
|
75
|
-
|
|
76
|
-
Components fall into the following **modules**:
|
|
77
|
-
|
|
78
|
-
**π Model I/O:**
|
|
79
|
-
|
|
80
|
-
This includes prompt management, prompt optimization, a generic interface for all LLMs, and common utilities for working with LLMs.
|
|
81
|
-
|
|
82
|
-
**π Retrieval:**
|
|
83
|
-
|
|
84
|
-
Data Augmented Generation involves specific types of chains that first interact with an external data source to fetch data for use in the generation step. Examples include summarization of long pieces of text and question/answering over specific data sources.
|
|
85
|
-
|
|
86
|
-
**π€ Agents:**
|
|
87
|
-
|
|
88
|
-
Agents allow an LLM autonomy over how a task is accomplished. Agents make decisions about which Actions to take, then take that Action, observe the result, and repeat until the task is complete. LangChain provides a [standard interface for agents](https://js.langchain.com/docs/concepts/#agents), along with [LangGraph.js](https://github.com/langchain-ai/langgraphjs/) for building custom agents.
|
|
89
|
-
|
|
90
48
|
## π Additional Resources
|
|
91
49
|
|
|
92
|
-
- [Getting started](https://
|
|
93
|
-
-
|
|
94
|
-
- [
|
|
95
|
-
- [
|
|
96
|
-
- [Langhain Forum](https://forum.langchain.com)
|
|
97
|
-
- [API Reference](https://api.js.langchain.com)
|
|
50
|
+
- [Getting started](https://docs.langchain.com/oss/javascript/langchain/overview): Installation, setting up the environment, simple examples
|
|
51
|
+
- [Learn](https://docs.langchain.com/oss/javascript/langchain/learn): Learn about the core concepts of LangChain.
|
|
52
|
+
- [LangChain Forum](https://forum.langchain.com): Connect with the community and share all of your technical questions, ideas, and feedback.
|
|
53
|
+
- [Chat LangChain](https://chat.langchain.com): Ask questions & chat with our documentaiton.
|
|
98
54
|
|
|
99
55
|
## π Contributing
|
|
100
56
|
|
|
@@ -103,7 +59,3 @@ As an open-source project in a rapidly developing field, we are extremely open t
|
|
|
103
59
|
For detailed information on how to contribute, see [here](https://github.com/langchain-ai/langchainjs/blob/main/CONTRIBUTING.md).
|
|
104
60
|
|
|
105
61
|
Please report any security issues or concerns following our [security guidelines](https://github.com/langchain-ai/langchainjs/blob/main/SECURITY.md).
|
|
106
|
-
|
|
107
|
-
## ποΈ Relationship with Python LangChain
|
|
108
|
-
|
|
109
|
-
This is built to integrate as seamlessly as possible with the [LangChain Python package](https://github.com/langchain-ai/langchain). Specifically, this means all objects (prompts, LLMs, chains, etc) are designed in a way where they can be serialized and shared between languages.
|
|
@@ -4,6 +4,7 @@ const require_utils = require('./utils.cjs');
|
|
|
4
4
|
const require_utils$1 = require('./nodes/utils.cjs');
|
|
5
5
|
const require_AgentNode = require('./nodes/AgentNode.cjs');
|
|
6
6
|
const require_ToolNode = require('./nodes/ToolNode.cjs');
|
|
7
|
+
const require_utils$2 = require('./middleware/utils.cjs');
|
|
7
8
|
const require_BeforeAgentNode = require('./nodes/BeforeAgentNode.cjs');
|
|
8
9
|
const require_BeforeModelNode = require('./nodes/BeforeModelNode.cjs');
|
|
9
10
|
const require_AfterModelNode = require('./nodes/AfterModelNode.cjs');
|
|
@@ -41,7 +42,7 @@ var ReactAgent = class {
|
|
|
41
42
|
* Create a schema that merges agent base schema with middleware state schemas
|
|
42
43
|
* Using Zod with withLangGraph ensures LangGraph Studio gets proper metadata
|
|
43
44
|
*/
|
|
44
|
-
const schema = require_annotation.createAgentAnnotationConditional(this.options.responseFormat !== void 0, this.options.middleware);
|
|
45
|
+
const schema = require_annotation.createAgentAnnotationConditional(this.options.responseFormat !== void 0, this.options.stateSchema, this.options.middleware);
|
|
45
46
|
const workflow = new __langchain_langgraph.StateGraph(schema, this.options.contextSchema);
|
|
46
47
|
const allNodeWorkflows = workflow;
|
|
47
48
|
const beforeAgentNodes = [];
|
|
@@ -77,7 +78,7 @@ var ReactAgent = class {
|
|
|
77
78
|
beforeAgentNodes.push({
|
|
78
79
|
index: i,
|
|
79
80
|
name,
|
|
80
|
-
allowed: m.
|
|
81
|
+
allowed: require_utils$2.getHookConstraint(m.beforeAgent)
|
|
81
82
|
});
|
|
82
83
|
allNodeWorkflows.addNode(name, beforeAgentNode, beforeAgentNode.nodeOptions);
|
|
83
84
|
}
|
|
@@ -87,7 +88,7 @@ var ReactAgent = class {
|
|
|
87
88
|
beforeModelNodes.push({
|
|
88
89
|
index: i,
|
|
89
90
|
name,
|
|
90
|
-
allowed: m.
|
|
91
|
+
allowed: require_utils$2.getHookConstraint(m.beforeModel)
|
|
91
92
|
});
|
|
92
93
|
allNodeWorkflows.addNode(name, beforeModelNode, beforeModelNode.nodeOptions);
|
|
93
94
|
}
|
|
@@ -97,7 +98,7 @@ var ReactAgent = class {
|
|
|
97
98
|
afterModelNodes.push({
|
|
98
99
|
index: i,
|
|
99
100
|
name,
|
|
100
|
-
allowed: m.
|
|
101
|
+
allowed: require_utils$2.getHookConstraint(m.afterModel)
|
|
101
102
|
});
|
|
102
103
|
allNodeWorkflows.addNode(name, afterModelNode, afterModelNode.nodeOptions);
|
|
103
104
|
}
|
|
@@ -107,7 +108,7 @@ var ReactAgent = class {
|
|
|
107
108
|
afterAgentNodes.push({
|
|
108
109
|
index: i,
|
|
109
110
|
name,
|
|
110
|
-
allowed: m.
|
|
111
|
+
allowed: require_utils$2.getHookConstraint(m.afterAgent)
|
|
111
112
|
});
|
|
112
113
|
allNodeWorkflows.addNode(name, afterAgentNode, afterAgentNode.nodeOptions);
|
|
113
114
|
}
|