File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -606,6 +606,9 @@ export const AnthropicChatCompleteStreamChunkTransform: (
606
606
streamState ,
607
607
strictOpenAiCompliance
608
608
) => {
609
+ if ( streamState . toolIndex == undefined ) {
610
+ streamState . toolIndex = - 1 ;
611
+ }
609
612
let chunk = responseChunk . trim ( ) ;
610
613
if (
611
614
chunk . startsWith ( 'event: ping' ) ||
@@ -724,9 +727,7 @@ export const AnthropicChatCompleteStreamChunkTransform: (
724
727
parsedChunk . type === 'content_block_start' &&
725
728
parsedChunk . content_block ?. type === 'tool_use' ;
726
729
if ( isToolBlockStart ) {
727
- streamState . toolIndex = streamState . toolIndex
728
- ? streamState . toolIndex + 1
729
- : 0 ;
730
+ streamState . toolIndex = streamState . toolIndex + 1 ;
730
731
}
731
732
const isToolBlockDelta : boolean =
732
733
parsedChunk . type === 'content_block_delta' &&
Original file line number Diff line number Diff line change @@ -792,6 +792,9 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
792
792
streamState ,
793
793
strictOpenAiCompliance
794
794
) => {
795
+ if ( streamState . toolIndex == undefined ) {
796
+ streamState . toolIndex = - 1 ;
797
+ }
795
798
let chunk = responseChunk . trim ( ) ;
796
799
797
800
if (
@@ -899,9 +902,7 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
899
902
parsedChunk . type === 'content_block_start' &&
900
903
parsedChunk . content_block ?. type === 'tool_use' ;
901
904
if ( isToolBlockStart ) {
902
- streamState . toolIndex = streamState . toolIndex
903
- ? streamState . toolIndex + 1
904
- : 0 ;
905
+ streamState . toolIndex = streamState . toolIndex + 1 ;
905
906
}
906
907
const isToolBlockDelta : boolean =
907
908
parsedChunk . type === 'content_block_delta' &&
You can’t perform that action at this time.
0 commit comments