Skip to content

Commit 35dd53f

Browse files
Handle special line when stream using ask-llm.go (#1)
1 parent 0f8671d commit 35dd53f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ask-llm.go

+9
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ func chat(messages []Message, handler func(string)) (string, error) {
9696
scanner := bufio.NewScanner(resp.Body)
9797
for scanner.Scan() {
9898
line := scanner.Text()
99+
if len(line) == 0 {
100+
continue
101+
}
102+
if line[0] == ':' {
103+
continue
104+
}
105+
if line == "data: [DONE]" {
106+
break
107+
}
99108
if strings.HasPrefix(line, "data: ") {
100109
payload := line[6:]
101110
var data struct {

0 commit comments

Comments
 (0)