Unified · Split
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | package responses |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | + "encoding/json" | |
| 4 | 5 | "strings" |
| 5 | 6 | |
| 6 | 7 | "github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/common" |
| @@ -340,7 +341,7 @@ func ConvertOpenAIResponsesRequestToGemini(modelName string, inputRawJSON []byte · 333 unmodified lines | ||
| 340 | 341 | // Set the raw JSON output directly (preserves string encoding) |
| 341 | 342 | if outputRaw != "" && outputRaw != "null" { |
| 342 | 343 | output := gjson.Parse(outputRaw) |
| 343 | − if output.Type == gjson.JSON { | |
| 344 | + if output.Type == gjson.JSON && json.Valid([]byte(output.Raw)) { | |
| 344 | 345 | functionResponse, _ = sjson.SetRaw(functionResponse, "functionResponse.response.result", output.Raw) |
| 345 | 346 | } else { |
| 346 | 347 | functionResponse, _ = sjson.Set(functionResponse, "functionResponse.response.result", outputRaw) |