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.
The arguments to the tool call
An optional identifier for the document.
Ideally this should be unique across the document collection and formatted as a UUID, but this will not be enforced.
Positional index of the block being updated.
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
// }
// ]