mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-07 02:07:52 +02:00
Branching
This commit is contained in:
@@ -329,8 +329,6 @@ export function useStream<
|
||||
|
||||
const [flatValues, flatPaths] = (() => {
|
||||
const result: ThreadState<StateType>[] = [];
|
||||
|
||||
// TODO: this is kinda ugly
|
||||
const flatPaths: Record<
|
||||
string,
|
||||
{ current: string[] | undefined; branches: string[][] | undefined }
|
||||
@@ -475,7 +473,6 @@ export function useStream<
|
||||
// @ts-expect-error
|
||||
if (checkpoint != null) delete checkpoint.thread_id;
|
||||
|
||||
// TODO: why non-existent assistant ID does not throw an error here?
|
||||
const run = (await client.runs.stream(usableThreadId, assistantId, {
|
||||
input: values as Record<string, unknown>,
|
||||
config: submitOptions?.config,
|
||||
@@ -496,6 +493,12 @@ export function useStream<
|
||||
streamMode,
|
||||
})) as AsyncGenerator<EventStreamEvent>;
|
||||
|
||||
// Unbranch things
|
||||
const newPath = submitOptions?.checkpoint?.checkpoint_id
|
||||
? flatPaths[submitOptions?.checkpoint?.checkpoint_id]?.current
|
||||
: undefined;
|
||||
if (newPath != null) setBranchPath(newPath ?? []);
|
||||
|
||||
// Assumption: we're setting the initial value
|
||||
// Used for instant feedback
|
||||
setStreamValues(() => {
|
||||
|
||||
Reference in New Issue
Block a user