|
28 | 28 | class="flex flex-col w-full" |
29 | 29 | :class="message.role === 'user' ? 'self-end' : 'self-start'" |
30 | 30 | > |
| 31 | + <ToolsGroup :toolGroup="groupToolCallParts(message)" /> |
31 | 32 | <template |
32 | 33 | v-for="part in getParts(message)" |
33 | 34 | :key="part.type" |
|
42 | 43 | @toggle-thoughts="() => clicks++" |
43 | 44 | > |
44 | 45 | </Message> |
45 | | - <ToolRenderer v-else :data="formatToolCallTextPart(part, message)" /> |
46 | 46 | </template> |
47 | 47 | </div> |
48 | 48 | <!-- Show a placeholder message if the last message is not of type 'text' or 'reasoning' --> |
@@ -72,6 +72,7 @@ import { IconArrowDownOutline } from '@iconify-prerendered/vue-flowbite'; |
72 | 72 | import SessionsHistory from './SessionsHistory.vue'; |
73 | 73 | import { useAgentStore } from './useAgentStore'; |
74 | 74 | import ToolRenderer from './ToolRenderer.vue'; |
| 75 | +import ToolsGroup from './ToolsGroup.vue'; |
75 | 76 |
|
76 | 77 | const scrollContainer = useTemplateRef('scrollContainer'); |
77 | 78 | const showScrollToBottomButton = ref(false); |
@@ -138,18 +139,34 @@ const formatToolCallTextPart = ((part: IPart, currentMessage: IMessage) => { |
138 | 139 | return null; |
139 | 140 | }); |
140 | 141 |
|
141 | | -// const groupToolCallParts = (parts: IPart[], message: IMessage) => { |
142 | | -// const groupedParts = []; |
143 | | -// const formatedToolParts = parts.map(part => { |
144 | | -// return formatToolCallTextPart(part, message) |
145 | | -// }); |
146 | | -// for( const[index, part] of formatedToolParts.entries()){ |
147 | | -// if(!part?.toolInfo) { |
148 | | -// continue; |
149 | | -// } |
150 | | - |
151 | | -// } |
152 | | -// } |
| 142 | +const groupToolCallParts = (message: IMessage) => { |
| 143 | + const groupedParts = []; |
| 144 | + let currentToolName = null; |
| 145 | + const parts = getParts(message); |
| 146 | + if (!parts) return []; |
| 147 | + const formatedToolParts = parts.map(part => { |
| 148 | + return formatToolCallTextPart(part as IPart, message) |
| 149 | + }); |
| 150 | + for( const[index, part] of formatedToolParts.entries()){ |
| 151 | + if(!part?.toolInfo) { |
| 152 | + continue; |
| 153 | + } |
| 154 | + console.log('part', part); |
| 155 | + if (part.toolInfo.toolName === currentToolName) { |
| 156 | + console.log('grouping part with tool name', currentToolName); |
| 157 | + groupedParts[groupedParts.length - 1].groupedTools.push(part); |
| 158 | + continue; |
| 159 | + } |
| 160 | + currentToolName = part.toolInfo.toolName; |
| 161 | + console.log('starting new group with tool name', currentToolName); |
| 162 | + groupedParts.push({ |
| 163 | + title: currentToolName, |
| 164 | + groupedTools: [part] |
| 165 | + }); |
| 166 | + } |
| 167 | + console.log('groupedParts', groupedParts); |
| 168 | + return groupedParts; |
| 169 | +} |
153 | 170 |
|
154 | 171 | const props = defineProps<{ |
155 | 172 | messages: IMessage[] |
|
0 commit comments