Tool: {groupKey} ({indices.length} calls)
{children}
);
};
```
### Group Consecutive Text Parts
Combine multiple text parts into cohesive blocks:
```tsx
import { FC, PropsWithChildren } from "react";
type MessagePartGroup = {
groupKey: string | undefined;
indices: number[];
};
const groupConsecutiveText = (parts: readonly any[]) => {
const groups: MessagePartGroup[] = [];
let currentGroup: number[] = [];
let isTextGroup = false;
for (let i = 0; i < parts.length; i++) {
const isText = parts[i].type === "text";
if (isText === isTextGroup && currentGroup.length > 0) {
currentGroup.push(i);
} else {
if (currentGroup.length > 0) {
groups.push({
groupKey: isTextGroup ? "text-block" : undefined,
indices: currentGroup,
});
}
currentGroup = [i];
isTextGroup = isText;
}
}
if (currentGroup.length > 0) {
groups.push({
groupKey: isTextGroup ? "text-block" : undefined,
indices: currentGroup,
});
}
return groups;
};
// Render text blocks with special formatting
const TextBlockGroup: FC<
PropsWithChildren<{ groupKey: string | undefined; indices: number[] }>
> = ({ groupKey, indices, children }) => {
if (groupKey === "text-block") {
return (