fix: update response body handling in OpenAI relay format
Some checks failed
Publish Docker image (Multi Registries) / Push Docker image to multiple registries (push) Has been cancelled
Some checks failed
Publish Docker image (Multi Registries) / Push Docker image to multiple registries (push) Has been cancelled
This commit is contained in:
parent
d09b99c1f0
commit
858585d974
@ -216,7 +216,16 @@ func OpenaiHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Respo
|
||||
|
||||
switch info.RelayFormat {
|
||||
case types.RelayFormatOpenAI:
|
||||
if forceFormat || usageModified {
|
||||
if usageModified {
|
||||
var bodyMap map[string]interface{}
|
||||
err = common.Unmarshal(responseBody, &bodyMap)
|
||||
if err != nil {
|
||||
return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponseBody, http.StatusInternalServerError)
|
||||
}
|
||||
bodyMap["usage"] = simpleResponse.Usage
|
||||
responseBody, _ = common.Marshal(bodyMap)
|
||||
}
|
||||
if forceFormat {
|
||||
responseBody, err = common.Marshal(simpleResponse)
|
||||
if err != nil {
|
||||
return nil, types.NewError(err, types.ErrorCodeBadResponseBody)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user