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

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

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

const rightChunks = [
new ToolCallChunk({
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:
// [
// new ToolCallChunk({
// name: "foo",
// args: '{"a":1}'
// index: 0
// })
// ]

Hierarchy (view full)

Implements

Constructors

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?: string

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

Methods

Generated using TypeDoc