fix agent and llm nodes when chat models streaming is off
This commit is contained in:
parent
32cd06cd28
commit
ed4cb2d35a
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue