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
3 changes: 2 additions & 1 deletion core/changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- fix: empty string handling in Anthropic provider to prevent sending empty content blocks in chat requests
- fix: empty string handling in Anthropic provider to prevent sending empty content blocks in chat requests
- fix: Gemini/Vertex tool conversion to append all function declarations to a single Tool object
15 changes: 6 additions & 9 deletions core/providers/gemini/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -2076,12 +2076,10 @@ func (r *GeminiGenerationRequest) convertParamsToGenerationConfigResponses(param

// convertResponsesToolsToGemini converts Responses tools to Gemini tools
func convertResponsesToolsToGemini(tools []schemas.ResponsesTool) []Tool {
var geminiTools []Tool
geminiTool := Tool{}

for _, tool := range tools {
if tool.Type == "function" {
geminiTool := Tool{}

// Extract function information from ResponsesExtendedTool
if tool.ResponsesToolFunction != nil {
if tool.Name != nil && tool.ResponsesToolFunction != nil {
Expand All @@ -2100,17 +2098,16 @@ func convertResponsesToolsToGemini(tools []schemas.ResponsesTool) []Tool {
return nil
}(),
}
geminiTool.FunctionDeclarations = []*FunctionDeclaration{funcDecl}
geminiTool.FunctionDeclarations = append(geminiTool.FunctionDeclarations, funcDecl)
}
}

if len(geminiTool.FunctionDeclarations) > 0 {
geminiTools = append(geminiTools, geminiTool)
}
}
}

return geminiTools
if len(geminiTool.FunctionDeclarations) > 0 {
return []Tool{geminiTool}
}
return []Tool{}
}

// convertResponsesToolChoiceToGemini converts Responses tool choice to Gemini tool config
Expand Down
12 changes: 6 additions & 6 deletions core/providers/gemini/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func convertParamsToGenerationConfig(params *schemas.ChatParameters, responseMod

// convertBifrostToolsToGemini converts Bifrost tools to Gemini format
func convertBifrostToolsToGemini(bifrostTools []schemas.ChatTool) []Tool {
var geminiTools []Tool
geminiTool := Tool{}

for _, tool := range bifrostTools {
if tool.Type == "" {
Expand All @@ -473,14 +473,14 @@ func convertBifrostToolsToGemini(bifrostTools []schemas.ChatTool) []Tool {
if tool.Function.Description != nil {
fd.Description = *tool.Function.Description
}
geminiTool := Tool{
FunctionDeclarations: []*FunctionDeclaration{fd},
}
geminiTools = append(geminiTools, geminiTool)
geminiTool.FunctionDeclarations = append(geminiTool.FunctionDeclarations, fd)
}
}

return geminiTools
if len(geminiTool.FunctionDeclarations) > 0 {
return []Tool{geminiTool}
}
return []Tool{}
}

// convertFunctionParametersToSchema converts Bifrost function parameters to Gemini Schema
Expand Down
2 changes: 1 addition & 1 deletion core/providers/vertex/vertex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestVertex(t *testing.T) {
MultiTurnConversation: true,
ToolCalls: true,
ToolCallsStreaming: true,
MultipleToolCalls: false, // multiple tool calls supported on gemini endpoint only if all tools are search tools
MultipleToolCalls: true,
End2EndToolCalling: true,
AutomaticFunctionCall: true,
ImageURL: true,
Expand Down
3 changes: 2 additions & 1 deletion transports/changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- chore: added max_tokens -> max_completion_tokens mapping for chat completions
- fix: empty string handling in Anthropic provider to prevent sending empty content blocks in chat requests
- fix: empty string handling in Anthropic provider to prevent sending empty content blocks in chat requests
- fix: Gemini/Vertex tool conversion to append all function declarations to a single Tool object