@cloudbase/agent-adapter-langgraph 1.0.1-alpha.28 → 1.0.1-alpha.30
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/dist/index.js +47 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -102,7 +102,7 @@ var LanggraphAgent = class extends AbstractAgent {
|
|
|
102
102
|
"Preparing stream input"
|
|
103
103
|
);
|
|
104
104
|
logger.trace?.({ messages, tools: input.tools }, "Full input messages");
|
|
105
|
-
const langChainMessages = aguiMessagesToLangChain(messages);
|
|
105
|
+
const langChainMessages = aguiMessagesToLangChain(messages, logger);
|
|
106
106
|
logger.trace?.(
|
|
107
107
|
{
|
|
108
108
|
langChainMessages,
|
|
@@ -539,7 +539,7 @@ var LanggraphAgent = class extends AbstractAgent {
|
|
|
539
539
|
traceId: serverContextData.traceId,
|
|
540
540
|
spanId: serverContextData.spanId,
|
|
541
541
|
traceFlags: serverContextData.traceFlags,
|
|
542
|
-
isRemote:
|
|
542
|
+
isRemote: true
|
|
543
543
|
};
|
|
544
544
|
this.observabilityCallback.setExternalParentContext(serverSpanContext, {
|
|
545
545
|
threadId: input.threadId,
|
|
@@ -557,7 +557,7 @@ var LanggraphAgent = class extends AbstractAgent {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
-
function aguiMessagesToLangChain(messages) {
|
|
560
|
+
function aguiMessagesToLangChain(messages, logger) {
|
|
561
561
|
return messages.map((message) => {
|
|
562
562
|
switch (message.role) {
|
|
563
563
|
case "user":
|
|
@@ -569,10 +569,34 @@ function aguiMessagesToLangChain(messages) {
|
|
|
569
569
|
type: "human"
|
|
570
570
|
};
|
|
571
571
|
} else {
|
|
572
|
+
const langChainContent = [];
|
|
573
|
+
for (const part of message.content) {
|
|
574
|
+
if (part.type === "text") {
|
|
575
|
+
langChainContent.push({ type: "text", text: part.text });
|
|
576
|
+
} else if (part.type === "binary") {
|
|
577
|
+
const imageUrl = convertBinaryToImageUrl(
|
|
578
|
+
part,
|
|
579
|
+
message.id,
|
|
580
|
+
logger
|
|
581
|
+
);
|
|
582
|
+
if (imageUrl) {
|
|
583
|
+
langChainContent.push({
|
|
584
|
+
type: "image_url",
|
|
585
|
+
image_url: { url: imageUrl }
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (langChainContent.length === 0) {
|
|
591
|
+
logger?.warn?.(
|
|
592
|
+
{ messageId: message.id },
|
|
593
|
+
"User message content array resulted in empty LangChain content"
|
|
594
|
+
);
|
|
595
|
+
}
|
|
572
596
|
return {
|
|
573
597
|
id: message.id,
|
|
574
598
|
role: message.role,
|
|
575
|
-
content:
|
|
599
|
+
content: langChainContent,
|
|
576
600
|
type: "human"
|
|
577
601
|
};
|
|
578
602
|
}
|
|
@@ -617,6 +641,22 @@ function isValidJson(json) {
|
|
|
617
641
|
return false;
|
|
618
642
|
}
|
|
619
643
|
}
|
|
644
|
+
function convertBinaryToImageUrl(part, messageId, logger) {
|
|
645
|
+
if (!part.mimeType.startsWith("image/")) {
|
|
646
|
+
logger?.debug?.(
|
|
647
|
+
{ mimeType: part.mimeType, messageId },
|
|
648
|
+
"Skipping non-image binary content"
|
|
649
|
+
);
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
if (part.url) {
|
|
653
|
+
return part.url;
|
|
654
|
+
}
|
|
655
|
+
if (part.data) {
|
|
656
|
+
return `data:${part.mimeType};base64,${part.data}`;
|
|
657
|
+
}
|
|
658
|
+
return void 0;
|
|
659
|
+
}
|
|
620
660
|
|
|
621
661
|
// src/checkpoint.ts
|
|
622
662
|
import {
|
|
@@ -878,16 +918,16 @@ import {
|
|
|
878
918
|
BaseCheckpointSaver as BaseCheckpointSaver3
|
|
879
919
|
} from "@langchain/langgraph";
|
|
880
920
|
|
|
881
|
-
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@
|
|
921
|
+
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@_2c17138888d9b381fe6f4d9db8b98c18/node_modules/@langchain/langgraph-checkpoint/dist/serde/types.js
|
|
882
922
|
var ERROR = "__error__";
|
|
883
923
|
var SCHEDULED = "__scheduled__";
|
|
884
924
|
var INTERRUPT = "__interrupt__";
|
|
885
925
|
var RESUME = "__resume__";
|
|
886
926
|
|
|
887
|
-
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@
|
|
927
|
+
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@_2c17138888d9b381fe6f4d9db8b98c18/node_modules/@langchain/langgraph-checkpoint/dist/serde/jsonplus.js
|
|
888
928
|
import { load } from "@langchain/core/load";
|
|
889
929
|
|
|
890
|
-
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@
|
|
930
|
+
// ../../../node_modules/.pnpm/@langchain+langgraph-checkpoint@1.0.0_@langchain+core@1.1.16_@opentelemetry+api@1.9.0_@_2c17138888d9b381fe6f4d9db8b98c18/node_modules/@langchain/langgraph-checkpoint/dist/base.js
|
|
891
931
|
function deepCopy(obj) {
|
|
892
932
|
if (typeof obj !== "object" || obj === null) return obj;
|
|
893
933
|
const newObj = Array.isArray(obj) ? [] : {};
|