mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
Fixed: #86
feat(translator): add support for single input string in Codex responses parser - Modified input parsing logic to handle cases where input is a single string instead of an array. - Added functionality to convert single string inputs into structured JSON format.
This commit is contained in:
@@ -34,9 +34,17 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inputResult := gjson.GetBytes(rawJSON, "input")
|
inputResult := gjson.GetBytes(rawJSON, "input")
|
||||||
inputResults := []gjson.Result{}
|
var inputResults []gjson.Result
|
||||||
if inputResult.Exists() && inputResult.IsArray() {
|
if inputResult.Exists() {
|
||||||
|
if inputResult.IsArray() {
|
||||||
inputResults = inputResult.Array()
|
inputResults = inputResult.Array()
|
||||||
|
} else if inputResult.Type == gjson.String {
|
||||||
|
newInput := `[{"type":"message","role":"user","content":[{"type":"input_text","text":""}]}]`
|
||||||
|
newInput, _ = sjson.Set(newInput, "0.content.0.text", inputResult.String())
|
||||||
|
inputResults = gjson.Parse(newInput).Array()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputResults = []gjson.Result{}
|
||||||
}
|
}
|
||||||
|
|
||||||
extractedSystemInstructions := false
|
extractedSystemInstructions := false
|
||||||
|
|||||||
Reference in New Issue
Block a user