fix: test

This commit is contained in:
ckt1031 2023-09-04 15:03:47 +08:00
parent cd3d1b9f1b
commit d384be868c

View File

@ -79,9 +79,7 @@ func testChannel(channel *model.Channel, request ChatRequest) (err error, openai
return errors.New(fmt.Sprintf("status code %d", resp.StatusCode)), nil return errors.New(fmt.Sprintf("status code %d", resp.StatusCode)), nil
} }
isStream := strings.HasPrefix(resp.Header.Get("Content-Type"), "text/event-stream") if channel.AllowStreaming == common.ChannelAllowStreamEnabled {
if channel.AllowStreaming == common.ChannelAllowStreamEnabled && isStream {
responseText := "" responseText := ""
scanner := bufio.NewScanner(resp.Body) scanner := bufio.NewScanner(resp.Body)
scanner.Split(func(data []byte, atEOF bool) (advance int, token []byte, err error) { scanner.Split(func(data []byte, atEOF bool) (advance int, token []byte, err error) {