refactor: split the relay controller

This commit is contained in:
JustSong
2023-06-19 10:28:55 +08:00
parent 5c18c559c3
commit f6fe34676f
4 changed files with 322 additions and 270 deletions

View File

@@ -77,3 +77,15 @@ func countTokenText(text string, model string) int {
token := tokenEncoder.Encode(text, nil, nil)
return len(token)
}
func errorWrapper(err error, code string, statusCode int) *OpenAIErrorWithStatusCode {
openAIError := OpenAIError{
Message: err.Error(),
Type: "one_api_error",
Code: code,
}
return &OpenAIErrorWithStatusCode{
OpenAIError: openAIError,
StatusCode: statusCode,
}
}