Skip to content

Commit 731a3bb

Browse files
committed
feat: remove obsolote method for parsing streamed response
1 parent b2b3e3a commit 731a3bb

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

src/components/KymaCompanion/api/getChatResponse.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getClusterConfig } from 'state/utils/getBackendInfo';
2-
import { parseWithNestedBrackets } from '../utils/parseNestedBrackets';
32
import { MessageChunk } from '../components/Chat/messages/Message';
43

54
interface ClusterAuth {
@@ -97,17 +96,12 @@ function readChunk(
9796
if (done) {
9897
return;
9998
}
100-
// Also handles the rare case of two chunks being sent at once
10199
const receivedString = decoder.decode(value, { stream: true });
102-
const chunks = parseWithNestedBrackets(receivedString).map(chunk => {
103-
return JSON.parse(chunk);
104-
});
105-
chunks.forEach(chunk => {
106-
if ('error' in chunk) {
107-
throw new Error(chunk.error);
108-
}
109-
handleChatResponse(chunk);
110-
});
100+
const chunk = JSON.parse(receivedString);
101+
if ('error' in chunk) {
102+
throw new Error(chunk.error);
103+
}
104+
handleChatResponse(chunk);
111105
readChunk(reader, decoder, handleChatResponse, handleError, sessionID);
112106
})
113107
.catch(error => {

src/components/KymaCompanion/utils/parseNestedBrackets.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)