From 2353276aa76bfbd79083a35b181a6356984052af Mon Sep 17 00:00:00 2001 From: Srayash Date: Mon, 21 Oct 2024 16:21:16 +0530 Subject: [PATCH] Bug Fix:react rect web widget prints undefined before printing an answer --- extensions/react-widget/src/components/DocsGPTWidget.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/react-widget/src/components/DocsGPTWidget.tsx b/extensions/react-widget/src/components/DocsGPTWidget.tsx index 83defbcf..01861274 100644 --- a/extensions/react-widget/src/components/DocsGPTWidget.tsx +++ b/extensions/react-widget/src/components/DocsGPTWidget.tsx @@ -453,8 +453,11 @@ export const DocsGPTWidget = ({ setQueries(updatedQueries); setStatus('idle') } + else if (data.type === 'source') { + // handle the case where data type === 'source' + } else { - const result = data.answer; + const result = data.answer ? data.answer : ''; //Fallback to an empty string if data.answer is undefined const streamingResponse = queries[queries.length - 1].response ? queries[queries.length - 1].response : ''; const updatedQueries = [...queries]; updatedQueries[updatedQueries.length - 1].response = streamingResponse + result;