diff options
author | 2025-02-21 02:42:11 +0000 | |
---|---|---|
committer | 2025-02-21 02:42:11 +0000 | |
commit | 06d7fc52da001b79191a107f81b35f7de8646d3e (patch) | |
tree | a82aa906ab4cd435b7e42ed95f13ed4ded65250a /usecaseui-portal/src/app/views/maas | |
parent | 31284fdb3a8448a0d776ebba6674cd27beced07a (diff) | |
parent | 0ca2d624e555c6e86c97e4ec447cbd512f093110 (diff) |
Diffstat (limited to 'usecaseui-portal/src/app/views/maas')
-rw-r--r-- | usecaseui-portal/src/app/views/maas/use/use-application.component.ts | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usecaseui-portal/src/app/views/maas/use/use-application.component.ts b/usecaseui-portal/src/app/views/maas/use/use-application.component.ts index abee90d0..b4546344 100644 --- a/usecaseui-portal/src/app/views/maas/use/use-application.component.ts +++ b/usecaseui-portal/src/app/views/maas/use/use-application.component.ts @@ -85,16 +85,22 @@ export class UseApplicationComponent implements OnInit, OnDestroy { this.chatHistory.push({ question: chatParam.question, questionId: chatParam.questionId, answer: '', status: 'typing' }); this.currentSSE.addEventListener('message', (event) => { const chat = this.chatHistory.find(chatItem => chatItem.questionId === questionId); + let msg = ''; + try { + msg = JSON.parse(event.data).answer; + } catch (error) { + this.message.error('Json parse failed.'); + } if (chat) { - if (['[DONE]', 'Network Error'].includes(event.data)) { + if (['[DONE]', 'Network Error'].includes(msg)) { chat.status = 'finished'; this.isGeneratingAnswer = false; - if (event.data === 'Network Error') { - this.updateAnswer(event, chat); + if (msg === 'Network Error') { + this.updateAnswer(msg, chat); } this.close(); } else { - this.updateAnswer(event, chat); + this.updateAnswer(msg, chat); } } }); @@ -109,8 +115,8 @@ export class UseApplicationComponent implements OnInit, OnDestroy { this.question = ''; } - updateAnswer(event: any, chat: Chat): void { - chat.answer += event.data.replace(/__SPACE__/g, ' '); + updateAnswer(msg: string, chat: Chat): void { + chat.answer += msg.replace(/__SPACE__/g, ' '); } async fetchAllApplication(): Promise<void> { |