@ai-sdk/langchain 3.0.0-beta.18 → 3.0.0-beta.180
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 +1194 -0
- package/README.md +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +391 -120
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/src/adapter.ts +74 -17
- package/src/transport.ts +9 -9
- package/src/types.ts +28 -12
- package/src/utils.ts +498 -94
- package/dist/index.d.mts +0 -159
- package/dist/index.mjs +0 -1087
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ const langchainMessages = await toBaseMessages(uiMessages);
|
|
|
47
47
|
|
|
48
48
|
const langchainStream = await graph.stream(
|
|
49
49
|
{ messages: langchainMessages },
|
|
50
|
-
{ streamMode: ['values', 'messages'] },
|
|
50
|
+
{ streamMode: ['values', 'messages', 'tools'] },
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
// Convert to UI message stream response
|
|
@@ -56,6 +56,8 @@ return createUIMessageStreamResponse({
|
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
Use the `tools` stream mode when you want to stream LangGraph tool progress. The adapter converts `on_tool_event` events to preliminary tool output (`preliminary: true`) and the final `on_tool_end` event to final tool output.
|
|
60
|
+
|
|
59
61
|
### Streaming with Callbacks
|
|
60
62
|
|
|
61
63
|
Use callbacks to access the final LangGraph state, handle errors, or detect aborts:
|
|
@@ -240,13 +242,14 @@ Converts a LangChain/LangGraph stream to an AI SDK `UIMessageStream`.
|
|
|
240
242
|
**Supported stream types:**
|
|
241
243
|
|
|
242
244
|
- **Model streams** - Direct `AIMessageChunk` streams from `model.stream()`
|
|
243
|
-
- **LangGraph streams** - Streams with `streamMode: ['values', 'messages']`
|
|
245
|
+
- **LangGraph streams** - Streams with `streamMode: ['values', 'messages']`, or `['values', 'messages', 'tools']` for tool progress
|
|
244
246
|
- **streamEvents** - Event streams from `agent.streamEvents()` or `model.streamEvents()`
|
|
245
247
|
|
|
246
248
|
**Supported LangGraph stream events:**
|
|
247
249
|
|
|
248
250
|
- `messages` - Streaming message chunks (text, tool calls)
|
|
249
251
|
- `values` - State updates that finalize pending message chunks
|
|
252
|
+
- `tools` - Tool progress events (`on_tool_event` emits preliminary tool output with `preliminary: true`, final `on_tool_end` emits final output)
|
|
250
253
|
- `custom` - Custom data events (emitted as `data-{type}` chunks)
|
|
251
254
|
|
|
252
255
|
**Supported streamEvents events:**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseMessage, AIMessageChunk } from '@langchain/core/messages';
|
|
2
|
-
import { UIMessage, UIMessageChunk,
|
|
2
|
+
import { ModelMessage, UIMessage, UIMessageChunk, ChatTransport, ChatRequestOptions } from 'ai';
|
|
3
3
|
import { RemoteGraph, RemoteGraphParams } from '@langchain/langgraph/remote';
|
|
4
4
|
|
|
5
5
|
/**
|