Interface UseStream<StateType, Bag>

interface UseStream<StateType, Bag> {
    assistantId: string;
    branch: string;
    client: Client<DefaultValues, DefaultValues, unknown>;
    error: unknown;
    experimental_branchTree: Sequence<StateType>;
    getMessagesMetadata: ((message, index?) => undefined | MessageMetadata<StateType>);
    history: ThreadState<StateType>[];
    interrupt: undefined | Interrupt<GetInterruptType<Bag>>;
    isLoading: boolean;
    joinStream: ((runId, lastEventId?, options?) => Promise<void>);
    messages: Message[];
    setBranch: ((branch) => void);
    stop: (() => void);
    submit: ((values, options?) => void);
    values: StateType;
}

Type Parameters

  • StateType extends Record<string, unknown> = Record<string, unknown>
  • Bag extends BagTemplate = BagTemplate

Properties

assistantId: string

The ID of the assistant to use.

branch: string

The current branch of the thread.

LangGraph SDK client used to send request and receive responses.

error: unknown

Last seen error from the thread or during streaming.

experimental_branchTree: Sequence<StateType>

Tree of all branches for the thread.

getMessagesMetadata: ((message, index?) => undefined | MessageMetadata<StateType>)

Get the metadata for a message, such as first thread state the message was seen in and branch information.

Type declaration

Returns

The metadata for the message.

Flattened history of thread states of a thread.

interrupt: undefined | Interrupt<GetInterruptType<Bag>>

Get the interrupt value for the stream if interrupted.

isLoading: boolean

Whether the stream is currently running.

joinStream: ((runId, lastEventId?, options?) => Promise<void>)

Join an active stream.

Type declaration

    • (runId, lastEventId?, options?): Promise<void>
    • Parameters

      Returns Promise<void>

messages: Message[]

Messages inferred from the thread. Will automatically update with incoming message chunks.

setBranch: ((branch) => void)

Set the branch of the thread.

Type declaration

    • (branch): void
    • Parameters

      • branch: string

      Returns void

stop: (() => void)

Stops the stream.

Type declaration

    • (): void
    • Returns void

submit: ((values, options?) => void)

Create and stream a run to the thread.

Type declaration

    • (values, options?): void
    • Parameters

      • values: undefined | null | GetUpdateType<Bag, StateType>
      • Optional options: SubmitOptions<StateType, GetConfigurableType<Bag>>

      Returns void

values: StateType

The current values of the thread.