Updated ChatMessage component to display calledTools (#5365)

This commit is contained in:
Henry Heng
2025-10-24 19:13:46 +01:00
committed by GitHub
parent 62d34066c9
commit 6f94d61f22
3 changed files with 116 additions and 5 deletions
@@ -1676,7 +1676,12 @@ class Agent_Agentflow implements INode {
const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer
if (response.tool_calls) {
sseStreamer.streamCalledToolsEvent(chatId, response.tool_calls)
const formattedToolCalls = response.tool_calls.map((toolCall: any) => ({
tool: toolCall.name || 'tool',
toolInput: toolCall.args,
toolOutput: ''
}))
sseStreamer.streamCalledToolsEvent(chatId, flatten(formattedToolCalls))
}
if (response.usage_metadata) {
@@ -1736,7 +1741,12 @@ class Agent_Agentflow implements INode {
// Stream tool calls if available
if (sseStreamer) {
sseStreamer.streamCalledToolsEvent(chatId, JSON.stringify(response.tool_calls))
const formattedToolCalls = response.tool_calls.map((toolCall: any) => ({
tool: toolCall.name || 'tool',
toolInput: toolCall.args,
toolOutput: ''
}))
sseStreamer.streamCalledToolsEvent(chatId, flatten(formattedToolCalls))
}
// Remove tool calls with no id
@@ -2045,7 +2055,12 @@ class Agent_Agentflow implements INode {
// Stream tool calls if available
if (sseStreamer) {
sseStreamer.streamCalledToolsEvent(chatId, JSON.stringify(response.tool_calls))
const formattedToolCalls = response.tool_calls.map((toolCall: any) => ({
tool: toolCall.name || 'tool',
toolInput: toolCall.args,
toolOutput: ''
}))
sseStreamer.streamCalledToolsEvent(chatId, flatten(formattedToolCalls))
}
// Remove tool calls with no id
@@ -13,6 +13,7 @@ import {
updateFlowState
} from '../utils'
import { processTemplateVariables } from '../../../src/utils'
import { flatten } from 'lodash'
class LLM_Agentflow implements INode {
label: string
@@ -892,7 +893,12 @@ class LLM_Agentflow implements INode {
const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer
if (response.tool_calls) {
sseStreamer.streamCalledToolsEvent(chatId, response.tool_calls)
const formattedToolCalls = response.tool_calls.map((toolCall: any) => ({
tool: toolCall.name || 'tool',
toolInput: toolCall.args,
toolOutput: ''
}))
sseStreamer.streamCalledToolsEvent(chatId, flatten(formattedToolCalls))
}
if (response.usage_metadata) {