@ai-sdk/langchain 3.0.120 → 3.0.123
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 +30 -0
- package/dist/index.d.ts +61 -58
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1811 -1577
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @ai-sdk/langchain
|
|
2
2
|
|
|
3
|
+
## 3.0.123
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ede5b89: chore: migrate package builds from tsup to tsdown
|
|
8
|
+
- Updated dependencies [05cdac6]
|
|
9
|
+
- Updated dependencies [4514fc1]
|
|
10
|
+
- Updated dependencies [ede5b89]
|
|
11
|
+
- Updated dependencies [2a625cf]
|
|
12
|
+
- Updated dependencies [50a26d5]
|
|
13
|
+
- ai@7.0.123
|
|
14
|
+
|
|
15
|
+
## 3.0.122
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [f3575f8]
|
|
20
|
+
- Updated dependencies [27ab8d4]
|
|
21
|
+
- ai@7.0.122
|
|
22
|
+
|
|
23
|
+
## 3.0.121
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [c5e90bb]
|
|
28
|
+
- Updated dependencies [868c475]
|
|
29
|
+
- Updated dependencies [119536f]
|
|
30
|
+
- Updated dependencies [9941f32]
|
|
31
|
+
- ai@7.0.121
|
|
32
|
+
|
|
3
33
|
## 3.0.120
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { RemoteGraph, RemoteGraphParams } from
|
|
4
|
-
|
|
1
|
+
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
2
|
+
import { ChatRequestOptions, ChatTransport, ModelMessage, UIMessage, UIMessageChunk } from "ai";
|
|
3
|
+
import { RemoteGraph, RemoteGraphParams } from "@langchain/langgraph/remote";
|
|
4
|
+
//#region src/stream-callbacks.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Callback options for stream lifecycle events.
|
|
7
7
|
*/
|
|
8
8
|
interface StreamCallbacks<TState = unknown> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
/** Called once when the stream is initialized. */
|
|
10
|
+
onStart?: () => Promise<void> | void;
|
|
11
|
+
/** Called for each tokenized message. */
|
|
12
|
+
onToken?: (token: string) => Promise<void> | void;
|
|
13
|
+
/** Called for each text chunk. */
|
|
14
|
+
onText?: (text: string) => Promise<void> | void;
|
|
15
|
+
/** Called with aggregated text when stream ends (success, error, or abort). */
|
|
16
|
+
onFinal?: (completion: string) => Promise<void> | void;
|
|
17
|
+
/**
|
|
18
|
+
* Called on successful completion. Receives final graph state for LangGraph
|
|
19
|
+
* streams (from last "values" event), undefined for other stream types.
|
|
20
|
+
*/
|
|
21
|
+
onFinish?: (finalState: TState | undefined) => Promise<void> | void;
|
|
22
|
+
/** Called when the stream encounters an error. */
|
|
23
|
+
onError?: (error: Error) => Promise<void> | void;
|
|
24
|
+
/** Called when the stream is aborted. */
|
|
25
|
+
onAbort?: () => Promise<void> | void;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/adapter.d.ts
|
|
28
29
|
/**
|
|
29
30
|
* Options for converting a LangChain stream to an AI SDK UIMessageStream.
|
|
30
31
|
*/
|
|
31
32
|
interface ToUIMessageStreamOptions<TState = unknown> extends StreamCallbacks<TState> {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Whether to emit the outer `start` chunk.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
sendStart?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to emit the outer `finish` chunk.
|
|
41
|
+
*
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
sendFinish?: boolean;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
47
|
* Converts AI SDK UIMessages to LangChain BaseMessage objects.
|
|
@@ -61,14 +62,14 @@ interface ToUIMessageStreamOptions<TState = unknown> extends StreamCallbacks<TSt
|
|
|
61
62
|
* const response = await model.invoke(langchainMessages);
|
|
62
63
|
* ```
|
|
63
64
|
*/
|
|
64
|
-
declare function toBaseMessages(messages: UIMessage[]): Promise<BaseMessage[]>;
|
|
65
|
+
export declare function toBaseMessages(messages: UIMessage[]): Promise<BaseMessage[]>;
|
|
65
66
|
/**
|
|
66
67
|
* Converts ModelMessages to LangChain BaseMessage objects.
|
|
67
68
|
*
|
|
68
69
|
* @param modelMessages - Array of ModelMessage objects from convertToModelMessages.
|
|
69
70
|
* @returns Array of LangChain BaseMessage objects.
|
|
70
71
|
*/
|
|
71
|
-
declare function convertModelMessages(modelMessages: ModelMessage[]): BaseMessage[];
|
|
72
|
+
export declare function convertModelMessages(modelMessages: ModelMessage[]): BaseMessage[];
|
|
72
73
|
/**
|
|
73
74
|
* Converts a LangChain stream to an AI SDK UIMessageStream.
|
|
74
75
|
*
|
|
@@ -126,18 +127,19 @@ declare function convertModelMessages(modelMessages: ModelMessage[]): BaseMessag
|
|
|
126
127
|
* });
|
|
127
128
|
* ```
|
|
128
129
|
*/
|
|
129
|
-
declare function toUIMessageStream<TState = unknown>(stream: AsyncIterable<AIMessageChunk> | ReadableStream, options?: ToUIMessageStreamOptions<TState>): ReadableStream<UIMessageChunk>;
|
|
130
|
-
|
|
130
|
+
export declare function toUIMessageStream<TState = unknown>(stream: AsyncIterable<AIMessageChunk> | ReadableStream, options?: ToUIMessageStreamOptions<TState>): ReadableStream<UIMessageChunk>;
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/transport.d.ts
|
|
131
133
|
/**
|
|
132
134
|
* Options for configuring a LangSmith deployment transport.
|
|
133
135
|
* Extends RemoteGraphParams but makes graphId optional (defaults to 'agent').
|
|
134
136
|
*/
|
|
135
137
|
type LangSmithDeploymentTransportOptions = Omit<RemoteGraphParams, 'graphId'> & {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
/**
|
|
139
|
+
* The ID of the graph to connect to.
|
|
140
|
+
* @default 'agent'
|
|
141
|
+
*/
|
|
142
|
+
graphId?: string;
|
|
141
143
|
};
|
|
142
144
|
/**
|
|
143
145
|
* A ChatTransport implementation for LangSmith/LangGraph deployments.
|
|
@@ -158,19 +160,20 @@ type LangSmithDeploymentTransportOptions = Omit<RemoteGraphParams, 'graphId'> &
|
|
|
158
160
|
* });
|
|
159
161
|
* ```
|
|
160
162
|
*/
|
|
161
|
-
declare class LangSmithDeploymentTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
163
|
+
export declare class LangSmithDeploymentTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
|
164
|
+
protected graph: RemoteGraph;
|
|
165
|
+
constructor(options: LangSmithDeploymentTransportOptions);
|
|
166
|
+
sendMessages(options: {
|
|
167
|
+
trigger: 'submit-message' | 'regenerate-message';
|
|
168
|
+
chatId: string;
|
|
169
|
+
messageId: string | undefined;
|
|
170
|
+
messages: UI_MESSAGE[];
|
|
171
|
+
abortSignal: AbortSignal | undefined;
|
|
172
|
+
} & ChatRequestOptions): Promise<ReadableStream<UIMessageChunk>>;
|
|
173
|
+
reconnectToStream(_options: {
|
|
174
|
+
chatId: string;
|
|
175
|
+
} & ChatRequestOptions): Promise<ReadableStream<UIMessageChunk> | null>;
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
export {
|
|
177
|
+
//#endregion
|
|
178
|
+
export type { LangSmithDeploymentTransportOptions, StreamCallbacks, ToUIMessageStreamOptions };
|
|
179
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/stream-callbacks.ts","../src/adapter.ts","../src/transport.ts"],"mappings":";;;;;;;UAGiB,gBAAgB;;EAE/B,gBAAgB;;EAGhB,WAAW,kBAAkB;;EAG7B,UAAU,iBAAiB;;EAG3B,WAAW,uBAAuB;;;;;EAMlC,YAAY,YAAY,uBAAuB;;EAG/C,WAAW,OAAO,UAAU;;EAG5B,gBAAgB;;;;;;;UCID,yBACf,0BACQ,gBAAgB;;;;;;EAMxB;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;wBAsBoB,eACpB,UAAU,cACT,QAAQ;;;;;;;wBAWK,qBACd,eAAe,iBACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsVa,kBAAkB,kBAChC,QAAQ,cAAc,kBAAkB,gBACxC,UAAU,yBAAyB,UAClC,eAAe;;;;;;;KC1ZN,sCAAsC,KAChD;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;qBAsBW,6BACX,mBAAmB,sBACR,cAAc;YACf,OAAO;EAEL,YAAA,SAAS;EAOf,aACJ;IACE;IACA;IACA;IACA,UAAU;IACV,aAAa;MACX,qBACH,QAAQ,eAAe;EAapB,kBACJ;IACE;MACE,qBACH,QAAQ,eAAe"}
|