langchain.js
    Preparing search index...

    Interface UseStream<StateType, Bag>

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

    Type Parameters

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

    Properties

    assistantId: string

    The ID of the assistant to use.

    branch: string

    The current branch of the thread.

    client: Client

    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: Message,
        index?: number,
    ) => undefined | MessageMetadata<StateType>

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

    Type Declaration

    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.

    isThreadLoading: boolean

    Whether the thread is currently being loaded.

    joinStream: (
        runId: string,
        lastEventId?: string,
        options?: { streamMode?: StreamMode | StreamMode[] },
    ) => Promise<void>

    Join an active stream.

    messages: Message[]

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

    setBranch: (branch: string) => void

    Set the branch of the thread.

    stop: () => Promise<void>

    Stops the stream.

    submit: (
        values: undefined | null | GetUpdateType<Bag, StateType>,
        options?: SubmitOptions<StateType, GetConfigurableType<Bag>>,
    ) => Promise<void>

    Create and stream a run to the thread.

    values: StateType

    The current values of the thread.