From 78357f630eaf4d2945b5acb052dad7b66c06f7d9 Mon Sep 17 00:00:00 2001 From: Malik Date: Sat, 7 Dec 2024 15:09:19 -0500 Subject: [PATCH] Added if statement --- examples/server/webui/src/main.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/server/webui/src/main.js b/examples/server/webui/src/main.js index 9b5b12329..dc02e1d1d 100644 --- a/examples/server/webui/src/main.js +++ b/examples/server/webui/src/main.js @@ -339,15 +339,16 @@ const mainApp = createApp({ endpoint: '/chat/completions', }; for await (const chunk of llama(prompt, params, config)) { - const stop = chunk.data.stop; - const addedContent = chunk.data.choices[0].delta.content; - const lastContent = this.pendingMsg.content || ''; - if (addedContent) { - this.pendingMsg = { - id: this.pendingMsg.id, - role: 'assistant', - content: lastContent + addedContent, - }; + if (chunk.data.choices) { + const addedContent = chunk.data.choices[0].delta.content; + const lastContent = this.pendingMsg.content || ''; + if (addedContent) { + this.pendingMsg = { + id: this.pendingMsg.id, + role: 'assistant', + content: lastContent + addedContent, + }; + } } }