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)