@ai-sdk/langchain 3.0.0-beta.87 → 3.0.0-beta.88
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 +11 -0
- package/dist/index.js +31 -50
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/index.d.mts +0 -159
- package/dist/index.mjs +0 -1106
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/langchain
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.88
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [ef992f8]
|
|
12
|
+
- ai@7.0.0-beta.88
|
|
13
|
+
|
|
3
14
|
## 3.0.0-beta.87
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
LangSmithDeploymentTransport: () => LangSmithDeploymentTransport,
|
|
24
|
-
convertModelMessages: () => convertModelMessages,
|
|
25
|
-
toBaseMessages: () => toBaseMessages,
|
|
26
|
-
toUIMessageStream: () => toUIMessageStream
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
1
|
// src/adapter.ts
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
import {
|
|
3
|
+
SystemMessage
|
|
4
|
+
} from "@langchain/core/messages";
|
|
5
|
+
import {
|
|
6
|
+
convertToModelMessages
|
|
7
|
+
} from "ai";
|
|
33
8
|
|
|
34
9
|
// src/utils.ts
|
|
35
|
-
|
|
10
|
+
import {
|
|
11
|
+
AIMessage,
|
|
12
|
+
HumanMessage,
|
|
13
|
+
ToolMessage,
|
|
14
|
+
AIMessageChunk
|
|
15
|
+
} from "@langchain/core/messages";
|
|
36
16
|
function parseLangGraphEvent(event) {
|
|
37
17
|
return event.length === 3 ? [event[1], event[2]] : [event[0], event[1]];
|
|
38
18
|
}
|
|
@@ -54,14 +34,14 @@ function convertToolResultPart(block) {
|
|
|
54
34
|
}
|
|
55
35
|
return "";
|
|
56
36
|
})();
|
|
57
|
-
return new
|
|
37
|
+
return new ToolMessage({
|
|
58
38
|
tool_call_id: block.toolCallId,
|
|
59
39
|
content
|
|
60
40
|
});
|
|
61
41
|
}
|
|
62
42
|
function convertAssistantContent(content) {
|
|
63
43
|
if (typeof content === "string") {
|
|
64
|
-
return new
|
|
44
|
+
return new AIMessage({ content });
|
|
65
45
|
}
|
|
66
46
|
const textParts = [];
|
|
67
47
|
const toolCalls = [];
|
|
@@ -76,7 +56,7 @@ function convertAssistantContent(content) {
|
|
|
76
56
|
});
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
|
-
return new
|
|
59
|
+
return new AIMessage({
|
|
80
60
|
content: textParts.join(""),
|
|
81
61
|
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
82
62
|
});
|
|
@@ -88,7 +68,7 @@ function getDefaultFilename(mediaType, prefix = "file") {
|
|
|
88
68
|
function convertUserContent(content) {
|
|
89
69
|
var _a;
|
|
90
70
|
if (typeof content === "string") {
|
|
91
|
-
return new
|
|
71
|
+
return new HumanMessage({ content });
|
|
92
72
|
}
|
|
93
73
|
const contentBlocks = [];
|
|
94
74
|
for (const part of content) {
|
|
@@ -215,11 +195,11 @@ function convertUserContent(content) {
|
|
|
215
195
|
}
|
|
216
196
|
}
|
|
217
197
|
if (contentBlocks.every((block) => block.type === "text")) {
|
|
218
|
-
return new
|
|
198
|
+
return new HumanMessage({
|
|
219
199
|
content: contentBlocks.map((block) => block.text).join("")
|
|
220
200
|
});
|
|
221
201
|
}
|
|
222
|
-
return new
|
|
202
|
+
return new HumanMessage({ content: contentBlocks });
|
|
223
203
|
}
|
|
224
204
|
function isToolResultPart(item) {
|
|
225
205
|
return item != null && typeof item === "object" && "type" in item && item.type === "tool-result";
|
|
@@ -304,7 +284,7 @@ function getMessageId(msg) {
|
|
|
304
284
|
return void 0;
|
|
305
285
|
}
|
|
306
286
|
function isAIMessageChunk(msg) {
|
|
307
|
-
if (
|
|
287
|
+
if (AIMessageChunk.isInstance(msg)) return true;
|
|
308
288
|
if (isPlainMessageObject(msg)) {
|
|
309
289
|
const obj = msg;
|
|
310
290
|
if ("type" in obj && obj.type === "ai") return true;
|
|
@@ -315,7 +295,7 @@ function isAIMessageChunk(msg) {
|
|
|
315
295
|
return false;
|
|
316
296
|
}
|
|
317
297
|
function isToolMessageType(msg) {
|
|
318
|
-
if (
|
|
298
|
+
if (ToolMessage.isInstance(msg)) return true;
|
|
319
299
|
if (isPlainMessageObject(msg)) {
|
|
320
300
|
const obj = msg;
|
|
321
301
|
if ("type" in obj && obj.type === "tool") return true;
|
|
@@ -327,7 +307,7 @@ function isToolMessageType(msg) {
|
|
|
327
307
|
}
|
|
328
308
|
function getMessageText(msg) {
|
|
329
309
|
var _a;
|
|
330
|
-
if (
|
|
310
|
+
if (AIMessageChunk.isInstance(msg)) {
|
|
331
311
|
return (_a = msg.text) != null ? _a : "";
|
|
332
312
|
}
|
|
333
313
|
if (msg == null || typeof msg !== "object") return "";
|
|
@@ -511,7 +491,7 @@ function processLangGraphEvent(event, state, controller) {
|
|
|
511
491
|
controller.enqueue({ type: "start-step" });
|
|
512
492
|
state.currentStep = langgraphStep;
|
|
513
493
|
}
|
|
514
|
-
if (
|
|
494
|
+
if (AIMessageChunk.isInstance(msg)) {
|
|
515
495
|
if (messageConcat[msgId]) {
|
|
516
496
|
messageConcat[msgId] = messageConcat[msgId].concat(
|
|
517
497
|
msg
|
|
@@ -683,7 +663,7 @@ function processLangGraphEvent(event, state, controller) {
|
|
|
683
663
|
const msgId = getMessageId(msg);
|
|
684
664
|
if (!msgId) continue;
|
|
685
665
|
let toolCalls;
|
|
686
|
-
if (
|
|
666
|
+
if (AIMessageChunk.isInstance(msg) || AIMessage.isInstance(msg)) {
|
|
687
667
|
toolCalls = msg.tool_calls;
|
|
688
668
|
} else if (isPlainMessageObject(msg)) {
|
|
689
669
|
const obj = msg;
|
|
@@ -806,7 +786,7 @@ function processLangGraphEvent(event, state, controller) {
|
|
|
806
786
|
|
|
807
787
|
// src/adapter.ts
|
|
808
788
|
async function toBaseMessages(messages) {
|
|
809
|
-
const modelMessages = await
|
|
789
|
+
const modelMessages = await convertToModelMessages(messages);
|
|
810
790
|
return convertModelMessages(modelMessages);
|
|
811
791
|
}
|
|
812
792
|
function convertModelMessages(modelMessages) {
|
|
@@ -826,7 +806,7 @@ function convertModelMessages(modelMessages) {
|
|
|
826
806
|
break;
|
|
827
807
|
}
|
|
828
808
|
case "system": {
|
|
829
|
-
result.push(new
|
|
809
|
+
result.push(new SystemMessage({ content: message.content }));
|
|
830
810
|
break;
|
|
831
811
|
}
|
|
832
812
|
case "user": {
|
|
@@ -1092,11 +1072,13 @@ function toUIMessageStream(stream, callbacks) {
|
|
|
1092
1072
|
}
|
|
1093
1073
|
|
|
1094
1074
|
// src/transport.ts
|
|
1095
|
-
|
|
1075
|
+
import {
|
|
1076
|
+
RemoteGraph
|
|
1077
|
+
} from "@langchain/langgraph/remote";
|
|
1096
1078
|
var LangSmithDeploymentTransport = class {
|
|
1097
1079
|
constructor(options) {
|
|
1098
1080
|
var _a;
|
|
1099
|
-
this.graph = new
|
|
1081
|
+
this.graph = new RemoteGraph({
|
|
1100
1082
|
...options,
|
|
1101
1083
|
graphId: (_a = options.graphId) != null ? _a : "agent"
|
|
1102
1084
|
});
|
|
@@ -1115,11 +1097,10 @@ var LangSmithDeploymentTransport = class {
|
|
|
1115
1097
|
throw new Error("Method not implemented.");
|
|
1116
1098
|
}
|
|
1117
1099
|
};
|
|
1118
|
-
|
|
1119
|
-
0 && (module.exports = {
|
|
1100
|
+
export {
|
|
1120
1101
|
LangSmithDeploymentTransport,
|
|
1121
1102
|
convertModelMessages,
|
|
1122
1103
|
toBaseMessages,
|
|
1123
1104
|
toUIMessageStream
|
|
1124
|
-
}
|
|
1105
|
+
};
|
|
1125
1106
|
//# sourceMappingURL=index.js.map
|