File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
examples/server/webui/src Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments