From 35dd53f44600f0122abe7e803a0e3bd9718a7a5c Mon Sep 17 00:00:00 2001 From: Kenji Hikmatullah <43457338+kenjihikmatullah@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:54:44 +0700 Subject: [PATCH] Handle special line when stream using ask-llm.go (#1) --- 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 {