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

@@ -3,6 +3,7 @@ package openai
import (
"bufio"
"context"
"net/http"
)
type ChatCompletionStreamChoiceDelta struct {
@@ -53,6 +54,9 @@ func (c *Client) CreateChatCompletionStream(
if err != nil {
return
}
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {
return nil, c.handleErrorResp(resp)
}
stream = &ChatCompletionStream{
streamReader: &streamReader[ChatCompletionStreamResponse]{