ToolCallChunk#

class langchain_core.messages.tool.ToolCallChunk[source]#

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.

Example:

left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]

(
    AIMessageChunk(content="", tool_call_chunks=left_chunks)
    + AIMessageChunk(content="", tool_call_chunks=right_chunks)
).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
name: str | None#

The name of the tool to be called.

args: str | None#

The arguments to the tool call.

id: str | None#

An identifier associated with the tool call.

index: int | None#

The index of the tool call in a sequence.

type: Literal['tool_call_chunk']#