mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Bugfix/Agent and llm nodes when chat models streaming is off (#5053)
fix agent and llm nodes when chat models streaming is off
This commit is contained in:
@@ -974,11 +974,15 @@ class Agent_Agentflow implements INode {
|
|||||||
}
|
}
|
||||||
} else if (!humanInput && !isStreamable && isLastNode && sseStreamer) {
|
} else if (!humanInput && !isStreamable && isLastNode && sseStreamer) {
|
||||||
// Stream whole response back to UI if not streaming and no tool calls
|
// Stream whole response back to UI if not streaming and no tool calls
|
||||||
let responseContent = JSON.stringify(response, null, 2)
|
let finalResponse = ''
|
||||||
if (typeof response.content === 'string') {
|
if (response.content && Array.isArray(response.content)) {
|
||||||
responseContent = response.content
|
finalResponse = response.content.map((item: any) => item.text).join('\n')
|
||||||
|
} else if (response.content && typeof response.content === 'string') {
|
||||||
|
finalResponse = response.content
|
||||||
|
} else {
|
||||||
|
finalResponse = JSON.stringify(response, null, 2)
|
||||||
}
|
}
|
||||||
sseStreamer.streamTokenEvent(chatId, responseContent)
|
sseStreamer.streamTokenEvent(chatId, finalResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate execution time
|
// Calculate execution time
|
||||||
|
|||||||
@@ -474,11 +474,15 @@ class LLM_Agentflow implements INode {
|
|||||||
// Stream whole response back to UI if this is the last node
|
// Stream whole response back to UI if this is the last node
|
||||||
if (isLastNode && options.sseStreamer) {
|
if (isLastNode && options.sseStreamer) {
|
||||||
const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer
|
const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer
|
||||||
let responseContent = JSON.stringify(response, null, 2)
|
let finalResponse = ''
|
||||||
if (typeof response.content === 'string') {
|
if (response.content && Array.isArray(response.content)) {
|
||||||
responseContent = response.content
|
finalResponse = response.content.map((item: any) => item.text).join('\n')
|
||||||
|
} else if (response.content && typeof response.content === 'string') {
|
||||||
|
finalResponse = response.content
|
||||||
|
} else {
|
||||||
|
finalResponse = JSON.stringify(response, null, 2)
|
||||||
}
|
}
|
||||||
sseStreamer.streamTokenEvent(chatId, responseContent)
|
sseStreamer.streamTokenEvent(chatId, finalResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user