fix: update response body handling in OpenAI relay format
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user