From 54cdf00e7e5bc046ef1574674a7fce36d185bb28 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Wed, 12 Feb 2025 10:40:46 +0000 Subject: [PATCH] Feat/stream flow variables (#4022) stream flow variables --- packages/server/src/utils/SSEStreamer.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/SSEStreamer.ts b/packages/server/src/utils/SSEStreamer.ts index 5fa5ca4d..a5327bad 100644 --- a/packages/server/src/utils/SSEStreamer.ts +++ b/packages/server/src/utils/SSEStreamer.ts @@ -194,7 +194,12 @@ export class SSEStreamer implements IServerSideEventStreamer { metadataJson['memoryType'] = apiResponse.memoryType } if (apiResponse.followUpPrompts) { - metadataJson['followUpPrompts'] = JSON.parse(apiResponse.followUpPrompts) + metadataJson['followUpPrompts'] = + typeof apiResponse.followUpPrompts === 'string' ? JSON.parse(apiResponse.followUpPrompts) : apiResponse.followUpPrompts + } + if (apiResponse.flowVariables) { + metadataJson['flowVariables'] = + typeof apiResponse.flowVariables === 'string' ? JSON.parse(apiResponse.flowVariables) : apiResponse.flowVariables } if (Object.keys(metadataJson).length > 0) { this.streamCustomEvent(chatId, 'metadata', metadataJson)