@@ -357,7 +357,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
357357 // Send initial content_block_start event
358358 contentBlockStart := schema.AnthropicStreamEvent {
359359 Type : "content_block_start" ,
360- Index : currentBlockIndex ,
360+ Index : intPtr ( currentBlockIndex ) ,
361361 ContentBlock : & schema.AnthropicContentBlock {Type : "text" , Text : "" },
362362 }
363363 sendAnthropicSSE (c , contentBlockStart )
@@ -376,7 +376,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
376376 if ! inToolCall && currentBlockIndex == 0 {
377377 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
378378 Type : "content_block_stop" ,
379- Index : currentBlockIndex ,
379+ Index : intPtr ( currentBlockIndex ) ,
380380 })
381381 currentBlockIndex ++
382382 inToolCall = true
@@ -386,7 +386,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
386386 tc := toolCalls [i ]
387387 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
388388 Type : "content_block_start" ,
389- Index : currentBlockIndex ,
389+ Index : intPtr ( currentBlockIndex ) ,
390390 ContentBlock : & schema.AnthropicContentBlock {
391391 Type : "tool_use" ,
392392 ID : fmt .Sprintf ("toolu_%s_%d" , id , i ),
@@ -395,15 +395,15 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
395395 })
396396 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
397397 Type : "content_block_delta" ,
398- Index : currentBlockIndex ,
398+ Index : intPtr ( currentBlockIndex ) ,
399399 Delta : & schema.AnthropicStreamDelta {
400400 Type : "input_json_delta" ,
401401 PartialJSON : tc .Arguments ,
402402 },
403403 })
404404 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
405405 Type : "content_block_stop" ,
406- Index : currentBlockIndex ,
406+ Index : intPtr ( currentBlockIndex ) ,
407407 })
408408 currentBlockIndex ++
409409 }
@@ -416,7 +416,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
416416 if ! inToolCall {
417417 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
418418 Type : "content_block_delta" ,
419- Index : 0 ,
419+ Index : intPtr ( 0 ) ,
420420 Delta : & schema.AnthropicStreamDelta {
421421 Type : "text_delta" ,
422422 Text : token ,
@@ -516,7 +516,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
516516 // Close the text content block
517517 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
518518 Type : "content_block_stop" ,
519- Index : currentBlockIndex ,
519+ Index : intPtr ( currentBlockIndex ) ,
520520 })
521521 currentBlockIndex ++
522522 inToolCall = true
@@ -528,7 +528,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
528528 }
529529 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
530530 Type : "content_block_start" ,
531- Index : currentBlockIndex ,
531+ Index : intPtr ( currentBlockIndex ) ,
532532 ContentBlock : & schema.AnthropicContentBlock {
533533 Type : "tool_use" ,
534534 ID : toolCallID ,
@@ -537,15 +537,15 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
537537 })
538538 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
539539 Type : "content_block_delta" ,
540- Index : currentBlockIndex ,
540+ Index : intPtr ( currentBlockIndex ) ,
541541 Delta : & schema.AnthropicStreamDelta {
542542 Type : "input_json_delta" ,
543543 PartialJSON : fc .Arguments ,
544544 },
545545 })
546546 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
547547 Type : "content_block_stop" ,
548- Index : currentBlockIndex ,
548+ Index : intPtr ( currentBlockIndex ) ,
549549 })
550550 currentBlockIndex ++
551551 toolCallsEmitted ++
@@ -557,7 +557,7 @@ func handleAnthropicStream(c echo.Context, id string, input *schema.AnthropicReq
557557 if ! inToolCall {
558558 sendAnthropicSSE (c , schema.AnthropicStreamEvent {
559559 Type : "content_block_stop" ,
560- Index : 0 ,
560+ Index : intPtr ( 0 ) ,
561561 })
562562 }
563563
@@ -598,6 +598,8 @@ func convertFuncsToOpenAITools(funcs functions.Functions) []functions.Tool {
598598 return tools
599599}
600600
601+ func intPtr (i int ) * int { return & i }
602+
601603func sendAnthropicSSE (c echo.Context , event schema.AnthropicStreamEvent ) {
602604 data , err := json .Marshal (event )
603605 if err != nil {
0 commit comments