mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-09 19:27:54 +02:00
fix: Allow configuring stream mode in useStream.joinStream() (#5146)
This commit is contained in:
@@ -621,7 +621,11 @@ export interface UseStream<
|
||||
/**
|
||||
* Join an active stream.
|
||||
*/
|
||||
joinStream: (runId: string) => Promise<void>;
|
||||
joinStream: (
|
||||
runId: string,
|
||||
lastEventId?: string,
|
||||
options?: { streamMode?: StreamMode | StreamMode[] },
|
||||
) => Promise<void>;
|
||||
}
|
||||
|
||||
type ConfigWithConfigurable<ConfigurableType extends Record<string, unknown>> =
|
||||
@@ -962,13 +966,18 @@ export function useStream<
|
||||
}
|
||||
}
|
||||
|
||||
const joinStream = async (runId: string, lastEventId?: string) => {
|
||||
const joinStream = async (
|
||||
runId: string,
|
||||
lastEventId?: string,
|
||||
options?: { streamMode?: StreamMode | StreamMode[] },
|
||||
) => {
|
||||
lastEventId ??= "-1";
|
||||
if (!threadId) return;
|
||||
await consumeStream(async (signal: AbortSignal) => {
|
||||
const stream = client.runs.joinStream(threadId, runId, {
|
||||
signal,
|
||||
lastEventId,
|
||||
streamMode: options?.streamMode,
|
||||
}) as AsyncGenerator<EventStreamEvent>;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user