Spaces:
Runtime error
Runtime error
Update api/chat.go
Browse files185 unmodified lines18618718818919019119219319419519619719819920020120220320420520620720820959 unmodified lines26927027126027227327427533 unmodified lines30931031131231331431520 unmodified lines336337338339340341342185 unmodified lines req.Header.Set("Sec-Fetch-Mode", "cors") req.Header.Set("Sec-Fetch-Dest", "empty") req.Header.Set("host", "arcane.getmerlin.in") var flusher http.Flusher if openAIReq.Stream { var ok bool flusher, ok = w.(http.Flusher) if !ok { http.Error(w, "Streaming unsupported!", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "text/event-stream") w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Connection", "keep-alive") w.Header().Set("X-Accel-Buffering", "no") w.Header().Set("Transfer-Encoding", "chunked") defer func() { if flusher != nil { flusher.Flush() } }() } else { w.Header().Set("Content-Type", "application/json") }59 unmodified lines return }
reader := bufio.NewReaderSize(resp.Body, 256) reader := bufio.NewReader(resp.Body) for { line, err := reader.ReadString('\n') if err != nil {33 unmodified lines
respData, _ := json.Marshal(openAIResp) fmt.Fprintf(w, "data: %s\n\n", string(respData)) flusher.Flush() } } }20 unmodified lines respData, _ := json.Marshal(finalResp) fmt.Fprintf(w, "data: %s\n\n", string(respData)) fmt.Fprintf(w, "data: [DONE]\n\n") flusher.Flush()}
func generateUUID() string {api/chat.go+15-1