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

Fix: Correctly relay FunctionResponse content for Gemini API
This commit is contained in:
Calcium-Ion
2025-06-06 01:46:23 +08:00
committed by GitHub
2 changed files with 6 additions and 16 deletions

View File

@@ -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"` Name string `json:"name"`
Response GeminiFunctionResponseContent `json:"response"` Response map[string]interface{} `json:"response"`
} }
type GeminiPartExecutableCode struct { type GeminiPartExecutableCode struct {

View File

@@ -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, Name: name,
Response: GeminiFunctionResponseContent{ Response: contentMap,
Name: name,
Content: content,
},
}
if content == nil {
functionResp.Response.Content = message.StringContent()
} }
*parts = append(*parts, GeminiPart{ *parts = append(*parts, GeminiPart{
FunctionResponse: functionResp, FunctionResponse: functionResp,
}) })