Skip to content

Commit

Permalink
Handle special line when stream using ask-llm.go (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjihikmatullah authored Dec 23, 2024
1 parent 0f8671d commit 35dd53f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ask-llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ func chat(messages []Message, handler func(string)) (string, error) {
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
if len(line) == 0 {
continue
}
if line[0] == ':' {
continue
}
if line == "data: [DONE]" {
break
}
if strings.HasPrefix(line, "data: ") {
payload := line[6:]
var data struct {
Expand Down

0 comments on commit 35dd53f

Please sign in to comment.