From 6cd0f932c966ccfb95fea5bfc8d72f88b7b408d6 Mon Sep 17 00:00:00 2001 From: MartialBE Date: Sat, 18 May 2024 17:22:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20gemini=20function=20call?= =?UTF-8?q?=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/gemini/type.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/providers/gemini/type.go b/providers/gemini/type.go index 65c7c9ce..42b68cfc 100644 --- a/providers/gemini/type.go +++ b/providers/gemini/type.go @@ -139,18 +139,19 @@ func OpenAIToGeminiChatContent(openaiContents []types.ChatCompletionMessage) ([] Parts: make([]GeminiPart, 0), } content.Role = ConvertRole(openaiContent.Role) - if openaiContent.Role == types.ChatMessageRoleFunction { - contents = append(contents, GeminiChatContent{ + if openaiContent.ToolCalls != nil { + content = GeminiChatContent{ Role: "model", Parts: []GeminiPart{ { FunctionCall: &GeminiFunctionCall{ - Name: *openaiContent.Name, + Name: openaiContent.ToolCalls[0].Function.Name, Args: map[string]interface{}{}, }, }, }, - }) + } + } else if openaiContent.Role == types.ChatMessageRoleTool { content = GeminiChatContent{ Role: "function", Parts: []GeminiPart{