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 @@ -786,6 +786,9 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
786
786
streamState ,
787
787
strictOpenAiCompliance
788
788
) => {
789
+ if ( streamState . toolIndex == undefined ) {
790
+ streamState . toolIndex = - 1 ;
791
+ }
789
792
let chunk = responseChunk . trim ( ) ;
790
793
791
794
if (
@@ -893,9 +896,7 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: (
893
896
parsedChunk . type === 'content_block_start' &&
894
897
parsedChunk . content_block ?. type === 'tool_use' ;
895
898
if ( isToolBlockStart ) {
896
- streamState . toolIndex = streamState . toolIndex
897
- ? streamState . toolIndex + 1
898
- : 0 ;
899
+ streamState . toolIndex = streamState . toolIndex + 1 ;
899
900
}
900
901
const isToolBlockDelta : boolean =
901
902
parsedChunk . type === 'content_block_delta' &&
You can’t perform that action at this time.
0 commit comments