@@ -349,7 +349,7 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
349349 if partial , exists := partialTools [idx ]; exists {
350350 // Parse the JSON to extract arguments for function call
351351 inputJSON := partial .input .String ()
352-
352+
353353 var args map [string ]any
354354 if inputJSON != "" {
355355 if err := json .Unmarshal ([]byte (inputJSON ), & args ); err != nil {
@@ -358,7 +358,7 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
358358 } else {
359359 args = make (map [string ]any )
360360 }
361-
361+
362362 // Create ToolUseBlock for conversation history
363363 // Use the accumulated JSON string to create proper Input document
364364 toolUse := types.ToolUseBlock {
@@ -367,7 +367,7 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
367367 Input : document .NewLazyDocument (args ),
368368 }
369369 completedTools = append (completedTools , toolUse )
370-
370+
371371 // Yield tool immediately with parsed arguments
372372 response := & bedrockStreamResponse {
373373 content : "" ,
@@ -379,7 +379,7 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
379379 if ! yield (response , nil ) {
380380 return
381381 }
382-
382+
383383 delete (partialTools , idx )
384384 }
385385
@@ -402,13 +402,13 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
402402 assistantMessage .Content = append (assistantMessage .Content ,
403403 & types.ContentBlockMemberText {Value : fullContent .String ()})
404404 }
405-
405+
406406 // Include completed tools in conversation history
407407 for _ , tool := range completedTools {
408408 assistantMessage .Content = append (assistantMessage .Content ,
409409 & types.ContentBlockMemberToolUse {Value : tool })
410410 }
411-
411+
412412 // Only add to history if there's content or tools
413413 if len (assistantMessage .Content ) > 0 {
414414 c .messages = append (c .messages , assistantMessage )
@@ -425,7 +425,7 @@ func (c *bedrockChat) SendStreaming(ctx context.Context, contents ...any) (ChatR
425425// following AWS Bedrock Converse API patterns
426426func (c * bedrockChat ) addContentsToHistory (contents []any ) error {
427427 var contentBlocks []types.ContentBlock
428-
428+
429429 for _ , content := range contents {
430430 switch c := content .(type ) {
431431 case string :
@@ -443,13 +443,13 @@ func (c *bedrockChat) addContentsToHistory(contents []any) error {
443443 }
444444 // Check for status field
445445 if statusVal , hasStatus := c .Result ["status" ]; hasStatus {
446- if statusStr , isString := statusVal .(string ); isString &&
447- (statusStr == "failed" || statusStr == "error" ) {
446+ if statusStr , isString := statusVal .(string ); isString &&
447+ (statusStr == "failed" || statusStr == "error" ) {
448448 status = types .ToolResultStatusError
449449 }
450450 }
451451 }
452-
452+
453453 // Convert to AWS Bedrock ToolResultBlock format per official docs
454454 toolResult := types.ToolResultBlock {
455455 ToolUseId : aws .String (c .ID ),
@@ -465,15 +465,15 @@ func (c *bedrockChat) addContentsToHistory(contents []any) error {
465465 return fmt .Errorf ("unhandled content type: %T" , content )
466466 }
467467 }
468-
468+
469469 if len (contentBlocks ) > 0 {
470470 // Add user message with all content blocks to conversation history
471471 c .messages = append (c .messages , types.Message {
472472 Role : types .ConversationRoleUser ,
473473 Content : contentBlocks ,
474474 })
475475 }
476-
476+
477477 return nil
478478}
479479
@@ -643,12 +643,12 @@ func (c *bedrockStreamCandidate) String() string {
643643// Parts returns the parts of the streaming candidate
644644func (c * bedrockStreamCandidate ) Parts () []Part {
645645 var parts []Part
646-
646+
647647 // Handle text content
648648 if c .content != "" {
649649 parts = append (parts , & bedrockTextPart {text : c .content })
650650 }
651-
651+
652652 // Handle tool calls with streaming args
653653 for i , toolUse := range c .toolUses {
654654 var args map [string ]any
@@ -660,7 +660,7 @@ func (c *bedrockStreamCandidate) Parts() []Part {
660660 args : args ,
661661 })
662662 }
663-
663+
664664 return parts
665665}
666666
0 commit comments