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, + }; + } } }