Skip to content

Commit

Permalink
feat: compatible with volceEngine websearch
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowpigy committed Feb 15, 2025
1 parent a1c8e62 commit c09cfdd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stream_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"fmt"
"io"
"net/http"
"strings"

utils "github.com/sashabaranov/go-openai/internal"
)

var (
headerData = []byte("data: ")
headerData = []byte("data:")
errorPrefix = []byte(`data: {"error":`)
)

Expand Down Expand Up @@ -90,7 +91,7 @@ func (stream *streamReader[T]) processLines() ([]byte, error) {
}

noPrefixLine := bytes.TrimPrefix(noSpaceLine, headerData)
if string(noPrefixLine) == "[DONE]" {
if strings.HasSuffix(string(noPrefixLine), "[DONE]") || strings.HasPrefix(string(noPrefixLine), "[DONE]") {
stream.isFinished = true
return nil, io.EOF
}
Expand Down

0 comments on commit c09cfdd

Please sign in to comment.