Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix: gemini thought signature handling in multi-turn conversations
8 changes: 2 additions & 6 deletions core/providers/bedrock/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,6 @@ func convertTextFormatToTool(ctx *context.Context, textConfig *schemas.Responses
return nil
}

if format.JSONSchema == nil {
return nil
}

toolName := "json_response"
if format.Name != nil && strings.TrimSpace(*format.Name) != "" {
toolName = strings.TrimSpace(*format.Name)
Expand All @@ -639,8 +635,8 @@ func convertTextFormatToTool(ctx *context.Context, textConfig *schemas.Responses
(*ctx) = context.WithValue(*ctx, schemas.BifrostContextKeyStructuredOutputToolName, toolName)

var schemaObj any
if format.JSONSchema.Schema != nil {
schemaObj = *format.JSONSchema.Schema
if format.JSONSchema != nil {
schemaObj = *format.JSONSchema
} else {
return nil // Schema is required for Bedrock tooling
}
Comment thread
TejasGhatte marked this conversation as resolved.
Expand Down
15 changes: 13 additions & 2 deletions core/providers/gemini/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,23 @@ func (response *GenerateContentResponse) ToBifrostChatResponse() *schemas.Bifros
callID = part.FunctionCall.ID
}

toolCalls = append(toolCalls, schemas.ChatAssistantMessageToolCall{
toolCall := schemas.ChatAssistantMessageToolCall{
Index: uint16(len(toolCalls)),
Type: schemas.Ptr(string(schemas.ChatToolChoiceTypeFunction)),
ID: &callID,
Function: function,
})
}

if part.ThoughtSignature != nil {
thoughtSig := base64.StdEncoding.EncodeToString(part.ThoughtSignature)
toolCall.ExtraContent = map[string]interface{}{
"google": map[string]interface{}{
"thought_signature": thoughtSig,
},
}
}

toolCalls = append(toolCalls, toolCall)
}

if part.FunctionResponse != nil {
Expand Down
Loading