History

Merge pull request #2162 from enieuwy/fix/responses-api-json-valid-check

Luis Pater committed 8 months agov6.8.55

Commit db63f9b2 parents 25f6c4a b24ae741 file · +2 −1Browse files

Unified · Split

internal/translator/gemini/openai/responses/gemini_openai-responses_request.go+2−1
@@ -1,6 +1,7 @@
1package responses1package responses
2 2
3import (3import (
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)