Merge pull request #1355 from Srayash/Srayash/issue#1283

Bug Fix: react web widget prints undefined before printing an answer.
This commit is contained in:
Alex
2024-10-21 15:42:10 +02:00
committed by GitHub

View File

@@ -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;