diff --git a/client.go b/client.go index 9ae8c57..1601adf 100644 --- a/client.go +++ b/client.go @@ -155,12 +155,12 @@ func (c *Client) newRequest( return req, nil } -// Response is an interface for a response. -type Response interface { +// response is an interface for a response. +type response interface { SetHeader(http.Header) } -func (c *Client) sendRequest(req *http.Request, v Response) error { +func (c *Client) sendRequest(req *http.Request, v response) error { req.Header.Set("Accept", "application/json") // Check whether Content-Type is already set, Upload Files API requires diff --git a/stream.go b/stream.go index b6d0b2f..bd597a2 100644 --- a/stream.go +++ b/stream.go @@ -39,8 +39,7 @@ func (c *Client) CreateCompletionStream( ctx, http.MethodPost, c.fullURL(completionsSuffix, withModel(request.Model)), - withBody(request), - ) + withBody(request)) if err != nil { return nil, err } @@ -65,7 +64,7 @@ type streamReader[T streamer] struct { response *http.Response errAccumulator ErrorAccumulator - http.Header // Header is the header of the response. + Header http.Header // Header is the header of the response. } // Recv receives a response from the stream. @@ -133,12 +132,10 @@ func (stream *streamReader[T]) unmarshalError() (errResp *ErrorResponse) { if len(errBytes) == 0 { return } - err := json.Unmarshal(errBytes, &errResp) if err != nil { errResp = nil } - return }