fix(translator): handle gjson strings in OpenAI response formatting

This commit is contained in:
Luis Pater
2025-11-08 00:41:56 +08:00
parent a7d105bd69
commit 682c4598ee

View File

@@ -2,6 +2,7 @@ package responses
import (
"bytes"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
)
@@ -147,6 +148,11 @@ func ConvertOpenAIResponsesRequestToOpenAIChatCompletions(modelName string, inpu
return true
})
} else if input.Type == gjson.String {
msg := "{}"
msg, _ = sjson.Set(msg, "role", "user")
msg, _ = sjson.Set(msg, "content", input.String())
out, _ = sjson.SetRaw(out, "messages.-1", msg)
}
// Convert tools from responses format to chat completions format