diff --git a/api/v1/chat.go b/api/v1/chat.go index 0f77860df2..51c624996b 100644 --- a/api/v1/chat.go +++ b/api/v1/chat.go @@ -118,6 +118,7 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) { } w.Write([]byte("data: ")) w.Write(resData) + w.Write([]byte("\n")) break } resData, err := json.Marshal(resp) @@ -140,6 +141,8 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) { }(globalChat.GetCookies()) } } + w.Write([]byte("data: [DONE]\n")) + flusher.Flush() } else { text, err := chat.Chat(prompt, msg) if err != nil {