From 23e45c11913a902426e65de249f3138c46e00f43 Mon Sep 17 00:00:00 2001 From: Kenji Hikmatullah Date: Sun, 15 Dec 2024 16:37:45 +0700 Subject: [PATCH] Handle special line when stream using ask-llm.go --- ask-llm.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ask-llm.go b/ask-llm.go index 4454b14..ebd5932 100644 --- a/ask-llm.go +++ b/ask-llm.go @@ -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 {