Added if statement

This commit is contained in:
Malik 2024-12-07 15:09:19 -05:00
parent 3573fa8e7b
commit 78357f630e

View file

@ -339,15 +339,16 @@ const mainApp = createApp({
endpoint: '/chat/completions', endpoint: '/chat/completions',
}; };
for await (const chunk of llama(prompt, params, config)) { for await (const chunk of llama(prompt, params, config)) {
const stop = chunk.data.stop; if (chunk.data.choices) {
const addedContent = chunk.data.choices[0].delta.content; const addedContent = chunk.data.choices[0].delta.content;
const lastContent = this.pendingMsg.content || ''; const lastContent = this.pendingMsg.content || '';
if (addedContent) { if (addedContent) {
this.pendingMsg = { this.pendingMsg = {
id: this.pendingMsg.id, id: this.pendingMsg.id,
role: 'assistant', role: 'assistant',
content: lastContent + addedContent, content: lastContent + addedContent,
}; };
}
} }
} }