File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -684,6 +684,30 @@ export class AssistantStream
684684 accValue . push ( ...deltaValue ) ; // Use spread syntax for efficient addition
685685 continue ;
686686 }
687+
688+ for ( const deltaEntry of deltaValue ) {
689+ if ( ! Core . isObj ( deltaEntry ) ) {
690+ throw new Error ( `Expected array delta entry to be an object but got: ${ deltaEntry } ` ) ;
691+ }
692+
693+ const index = deltaEntry [ 'index' ] ;
694+ if ( index == null ) {
695+ console . error ( deltaEntry ) ;
696+ throw new Error ( 'Expected array delta entry to have an `index` property' ) ;
697+ }
698+
699+ if ( typeof index !== 'number' ) {
700+ throw new Error ( `Expected array delta entry \`index\` property to be a number but got ${ index } ` ) ;
701+ }
702+
703+ const accEntry = accValue [ index ] ;
704+ if ( accEntry == null ) {
705+ accValue . push ( deltaEntry ) ;
706+ } else {
707+ accValue [ index ] = this . accumulateDelta ( accEntry , deltaEntry ) ;
708+ }
709+ }
710+ continue ;
687711 } else {
688712 throw Error ( `Unhandled record type: ${ key } , deltaValue: ${ deltaValue } , accValue: ${ accValue } ` ) ;
689713 }
You can’t perform that action at this time.
0 commit comments