mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-25 13:15:45 -04:00
fix: handle subgraph custom events in stream processing (#1459)
Co-authored-by: Tat Dat Duong <david@duong.cz>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@langchain/langgraph-sdk": patch
|
||||
---
|
||||
|
||||
fix(sdk): handle subgraph custom events in stream processing of useStream
|
||||
@@ -1065,8 +1065,13 @@ export function useStream<
|
||||
}
|
||||
|
||||
if (event === "updates") options.onUpdateEvent?.(data);
|
||||
if (event === "custom")
|
||||
options.onCustomEvent?.(data, {
|
||||
if (
|
||||
event === "custom" ||
|
||||
// if `streamSubgraphs: true`, then we also want
|
||||
// to also receive custom events from subgraphs
|
||||
event.startsWith("custom|")
|
||||
)
|
||||
options.onCustomEvent?.(data as CustomType, {
|
||||
mutate: getMutateFn("stream", historyValues),
|
||||
});
|
||||
if (event === "metadata") options.onMetadataEvent?.(data);
|
||||
@@ -1203,6 +1208,7 @@ export function useStream<
|
||||
onThreadId(thread.thread_id);
|
||||
usableThreadId = thread.thread_id;
|
||||
}
|
||||
if (!usableThreadId) throw new Error("Failed to obtain valid thread ID.");
|
||||
|
||||
const streamMode = unique([
|
||||
...(submitOptions?.streamMode ?? []),
|
||||
|
||||
Reference in New Issue
Block a user