Bug Fix:react rect web widget prints undefined before printing an answer

This commit is contained in:
Srayash
2024-10-21 16:21:16 +05:30
parent 2c25f4a4c0
commit 2353276aa7

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;