Просмотр исходного кода

Merge pull request #1166 from RedwindA/fix/gemini-functionResponse

Fix: Correctly relay FunctionResponse content for Gemini API
Calcium-Ion 9 месяцев назад
Родитель
Сommit
b0a5d01e1d
2 измененных файлов с 6 добавлено и 16 удалено
  1. 2 7
      relay/channel/gemini/dto.go
  2. 4 9
      relay/channel/gemini/relay-gemini.go

+ 2 - 7
relay/channel/gemini/dto.go

@@ -27,14 +27,9 @@ type FunctionCall struct {
 	Arguments    any    `json:"args"`
 	Arguments    any    `json:"args"`
 }
 }
 
 
-type GeminiFunctionResponseContent struct {
-	Name    string `json:"name"`
-	Content any    `json:"content"`
-}
-
 type FunctionResponse struct {
 type FunctionResponse struct {
-	Name     string                        `json:"name"`
-	Response GeminiFunctionResponseContent `json:"response"`
+	Name     string                 `json:"name"`
+	Response map[string]interface{} `json:"response"`
 }
 }
 
 
 type GeminiPartExecutableCode struct {
 type GeminiPartExecutableCode struct {

+ 4 - 9
relay/channel/gemini/relay-gemini.go

@@ -186,17 +186,12 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest, info *relaycommon
 			} else if val, exists := tool_call_ids[message.ToolCallId]; exists {
 			} else if val, exists := tool_call_ids[message.ToolCallId]; exists {
 				name = val
 				name = val
 			}
 			}
-			content := common.StrToMap(message.StringContent())
+			contentMap := common.StrToMap(message.StringContent())
 			functionResp := &FunctionResponse{
 			functionResp := &FunctionResponse{
-				Name: name,
-				Response: GeminiFunctionResponseContent{
-					Name:    name,
-					Content: content,
-				},
-			}
-			if content == nil {
-				functionResp.Response.Content = message.StringContent()
+				Name:     name,
+				Response: contentMap,
 			}
 			}
+
 			*parts = append(*parts, GeminiPart{
 			*parts = append(*parts, GeminiPart{
 				FunctionResponse: functionResp,
 				FunctionResponse: functionResp,
 			})
 			})