Skip to content

Commit 78357f6

Browse files
committed
Added if statement
1 parent 3573fa8 commit 78357f6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

examples/server/webui/src/main.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,16 @@ const mainApp = createApp({
339339
endpoint: '/chat/completions',
340340
};
341341
for await (const chunk of llama(prompt, params, config)) {
342-
const stop = chunk.data.stop;
343-
const addedContent = chunk.data.choices[0].delta.content;
344-
const lastContent = this.pendingMsg.content || '';
345-
if (addedContent) {
346-
this.pendingMsg = {
347-
id: this.pendingMsg.id,
348-
role: 'assistant',
349-
content: lastContent + addedContent,
350-
};
342+
if (chunk.data.choices) {
343+
const addedContent = chunk.data.choices[0].delta.content;
344+
const lastContent = this.pendingMsg.content || '';
345+
if (addedContent) {
346+
this.pendingMsg = {
347+
id: this.pendingMsg.id,
348+
role: 'assistant',
349+
content: lastContent + addedContent,
350+
};
351+
}
351352
}
352353
}
353354

0 commit comments

Comments
 (0)