diff --git a/components/model/openai/types.go b/components/model/openai/types.go index 1aee16675..a7fd6d531 100644 --- a/components/model/openai/types.go +++ b/components/model/openai/types.go @@ -39,6 +39,7 @@ type APIError struct { Type string `json:"type"` HTTPStatus string `json:"-"` HTTPStatusCode int `json:"-"` + InnerError error `json:"-"` } func (e *APIError) Error() string { @@ -49,6 +50,10 @@ func (e *APIError) Error() string { return e.Message } +func (e *APIError) Unwrap() error { + return e.InnerError +} + func convOrigAPIError(err error) error { apiErr := &openai2.APIError{} if errors.As(err, &apiErr) { @@ -59,6 +64,7 @@ func convOrigAPIError(err error) error { Type: apiErr.Type, HTTPStatus: apiErr.HTTPStatus, HTTPStatusCode: apiErr.HTTPStatusCode, + InnerError: err, } } return err