Skip to content

Commit db63f9b

Browse files
authored
Merge pull request router-for-me#2162 from enieuwy/fix/responses-api-json-valid-check
fix: validate JSON before raw-embedding function call outputs in Responses API
2 parents 25f6c4a + b24ae74 commit db63f9b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

internal/translator/gemini/openai/responses/gemini_openai-responses_request.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package responses
22

33
import (
4+
"encoding/json"
45
"strings"
56

67
"github.com/router-for-me/CLIProxyAPI/v6/internal/translator/gemini/common"
@@ -340,7 +341,7 @@ func ConvertOpenAIResponsesRequestToGemini(modelName string, inputRawJSON []byte
340341
// Set the raw JSON output directly (preserves string encoding)
341342
if outputRaw != "" && outputRaw != "null" {
342343
output := gjson.Parse(outputRaw)
343-
if output.Type == gjson.JSON {
344+
if output.Type == gjson.JSON && json.Valid([]byte(output.Raw)) {
344345
functionResponse, _ = sjson.SetRaw(functionResponse, "functionResponse.response.result", output.Raw)
345346
} else {
346347
functionResponse, _ = sjson.Set(functionResponse, "functionResponse.response.result", outputRaw)

0 commit comments

Comments
 (0)