Skip to content

Commit c6f6c9e

Browse files
authored
fix(streaming-response): add in handling for the response block when streaming (#1568)
1 parent 2d7ba91 commit c6f6c9e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/sim/lib/workflows/streaming.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ export async function createStreamingResponse(
9696

9797
for (const outputId of matchingOutputs) {
9898
const path = extractPathFromOutputId(outputId, blockId)
99-
const outputValue = traverseObjectPath(output, path)
99+
100+
// Response blocks have their data nested under 'response'
101+
let outputValue = traverseObjectPath(output, path)
102+
if (outputValue === undefined && output.response) {
103+
outputValue = traverseObjectPath(output.response, path)
104+
}
100105

101106
if (outputValue !== undefined) {
102107
const formattedOutput =
@@ -150,7 +155,11 @@ export async function createStreamingResponse(
150155
if (result.logs) {
151156
const blockLog = result.logs.find((log: any) => log.blockId === blockId)
152157
if (blockLog?.output) {
153-
const value = traverseObjectPath(blockLog.output, path)
158+
// Response blocks have their data nested under 'response'
159+
let value = traverseObjectPath(blockLog.output, path)
160+
if (value === undefined && blockLog.output.response) {
161+
value = traverseObjectPath(blockLog.output.response, path)
162+
}
154163
if (value !== undefined) {
155164
// Store it in a structured way
156165
if (!minimalResult.output[blockId]) {

0 commit comments

Comments
 (0)