fix: chat stream resp error (#259)

This commit is contained in:
Liu Shuang
2023-04-19 20:05:00 +08:00
committed by GitHub
parent 3b10c032b6
commit d6ab1b3a4f
8 changed files with 146 additions and 33 deletions

View File

@@ -7,17 +7,17 @@ import (
// APIError provides error information returned by the OpenAI API.
type APIError struct {
Code any `json:"code,omitempty"`
Message string `json:"message"`
Param *string `json:"param,omitempty"`
Type string `json:"type"`
StatusCode int `json:"-"`
Code any `json:"code,omitempty"`
Message string `json:"message"`
Param *string `json:"param,omitempty"`
Type string `json:"type"`
HTTPStatusCode int `json:"-"`
}
// RequestError provides informations about generic request errors.
type RequestError struct {
StatusCode int
Err error
HTTPStatusCode int
Err error
}
type ErrorResponse struct {
@@ -73,7 +73,7 @@ func (e *RequestError) Error() string {
if e.Err != nil {
return e.Err.Error()
}
return fmt.Sprintf("status code %d", e.StatusCode)
return fmt.Sprintf("status code %d", e.HTTPStatusCode)
}
func (e *RequestError) Unwrap() error {