A chunk of a tool call (yielded when streaming).
When merging ToolCallChunk objects (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)]ToolCallChunk()The name of the tool to be called.
The arguments to the tool call as a JSON-parseable string.
An identifier associated with the tool call.
An identifier is needed to associate a tool call request with a tool call result in events when multiple concurrent tool calls are made.
The index of the tool call in a sequence.
Used for merging chunks.
Used for discrimination.