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