langchain.js
    Preparing search index...

    Interface ToolCallChunk<TName>

    A chunk of a tool call (e.g., as part of a stream). When merging ToolCallChunks (e.g., via AIMessageChunk.add), all string attributes are concatenated. Chunks are only merged if their values of index are equal and not None.

    const leftChunks = [
    {
    name: "foo",
    args: '{"a":',
    index: 0
    }
    ];

    const leftAIMessageChunk = new AIMessageChunk({
    content: "",
    tool_call_chunks: leftChunks
    });

    const rightChunks = [
    {
    name: undefined,
    args: '1}',
    index: 0
    }
    ];

    const rightAIMessageChunk = new AIMessageChunk({
    content: "",
    tool_call_chunks: rightChunks
    });

    const result = leftAIMessageChunk.concat(rightAIMessageChunk);
    // result.tool_call_chunks is equal to:
    // [
    // {
    // name: "foo",
    // args: '{"a":1}'
    // index: 0
    // }
    // ]
    interface ToolCallChunk<TName extends string = string> {
        args?: string;
        id?: string;
        index?: number;
        name?: TName;
        type?: "tool_call_chunk";
    }

    Type Parameters

    • TName extends string = string
    Index

    Properties

    args?: string

    If provided, a JSON substring of the arguments to the tool call

    id?: string

    If provided, a substring of an identifier for the tool call

    index?: number

    If provided, the index of the tool call in a sequence

    name?: TName

    If provided, a substring of the name of the tool to be called

    type?: "tool_call_chunk"