(w http.ResponseWriter, model string, chatID, data string)
| 102 | } |
| 103 | |
| 104 | func SendChatData(w http.ResponseWriter, model string, chatID, data string) { |
| 105 | dataRune := []rune(data) |
| 106 | for _, d := range dataRune { |
| 107 | respData := ConstructChatCompletionStreamReponse(model, chatID, string(d)) |
| 108 | byteData, _ := json.Marshal(respData) |
| 109 | _, _ = fmt.Fprintf(w, "data: %s\n\n", string(byteData)) |
| 110 | w.(http.Flusher).Flush() |
| 111 | time.Sleep(1 * time.Millisecond) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | func SendChatDone(w http.ResponseWriter) { |
| 116 | _, _ = fmt.Fprintf(w, "data: [DONE]") |
no test coverage detected