sendStreamData
(w http.ResponseWriter, data StreamResponse)
| 175 | |
| 176 | // sendStreamData |
| 177 | func sendStreamData(w http.ResponseWriter, data StreamResponse) { |
| 178 | jsonData, err := json.Marshal(data) |
| 179 | if err != nil { |
| 180 | return |
| 181 | } |
| 182 | |
| 183 | _, _ = fmt.Fprintf(w, "data: %s\n\n", string(jsonData)) |
| 184 | if f, ok := w.(http.Flusher); ok { |
| 185 | f.Flush() |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | func (c *AIController) ChatCompletions(ctx *gin.Context) { |
| 190 | if !c.ensureAIChatEnabled(ctx) { |
no test coverage detected