first commit
This commit is contained in:
19
core/providers/vllm/utils.go
Normal file
19
core/providers/vllm/utils.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package vllm
|
||||
|
||||
import (
|
||||
"github.com/bytedance/sonic"
|
||||
providerUtils "github.com/maximhq/bifrost/core/providers/utils"
|
||||
schemas "github.com/maximhq/bifrost/core/schemas"
|
||||
)
|
||||
|
||||
func HandleVLLMResponse[T any](responseBody []byte, response *T, requestBody []byte, sendBackRawRequest bool, sendBackRawResponse bool) (rawRequest interface{}, rawResponse interface{}, bifrostErr *schemas.BifrostError) {
|
||||
var errorResp schemas.BifrostError
|
||||
rawRequest, rawResponse, bifrostErr = providerUtils.HandleProviderResponse(responseBody, response, requestBody, sendBackRawRequest, sendBackRawResponse)
|
||||
if bifrostErr != nil {
|
||||
return rawRequest, rawResponse, bifrostErr
|
||||
}
|
||||
if err := sonic.Unmarshal(responseBody, &errorResp); err == nil && errorResp.Error != nil && errorResp.Error.Message != "" {
|
||||
return rawRequest, rawResponse, &errorResp
|
||||
}
|
||||
return rawRequest, rawResponse, nil
|
||||
}
|
||||
Reference in New Issue
Block a user