mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
fix(translator): handle gjson strings in OpenAI response formatting
This commit is contained in:
@@ -2,6 +2,7 @@ package responses
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"github.com/tidwall/sjson"
|
"github.com/tidwall/sjson"
|
||||||
)
|
)
|
||||||
@@ -147,6 +148,11 @@ func ConvertOpenAIResponsesRequestToOpenAIChatCompletions(modelName string, inpu
|
|||||||
|
|
||||||
return true
|
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
|
// Convert tools from responses format to chat completions format
|
||||||
|
|||||||
Reference in New Issue
Block a user