Spaces:
Runtime error
Runtime error
Update api/chat.go
Browse files185 unmodified lines18618718818919019119219319419519619759 unmodified lines25725825926026126226333 unmodified lines29729829930030130220 unmodified lines323324325326327328185 unmodified linesreq.Header.Set("Sec-Fetch-Mode", "cors")req.Header.Set("Sec-Fetch-Dest", "empty")req.Header.Set("host", "arcane.getmerlin.in")if openAIReq.Stream {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")} else {w.Header().Set("Content-Type", "application/json")}59 unmodified linesreturn}reader := bufio.NewReaderSize(resp.Body, 256)for {line, err := reader.ReadString('\n')if err != nil {33 unmodified linesrespData, _ := json.Marshal(openAIResp)fmt.Fprintf(w, "data: %s\n\n", string(respData))}}}20 unmodified linesrespData, _ := json.Marshal(finalResp)fmt.Fprintf(w, "data: %s\n\n", string(respData))fmt.Fprintf(w, "data: [DONE]\n\n")}func generateUUID() string {185 unmodified lines18618718818919019119219319419519619719819920020120220320420520620720820959 unmodified lines26927027127227327427533 unmodified lines30931031131231331431520 unmodified lines336337338339340341342185 unmodified linesreq.Header.Set("Sec-Fetch-Mode", "cors")req.Header.Set("Sec-Fetch-Dest", "empty")req.Header.Set("host", "arcane.getmerlin.in")var flusher http.Flusherif openAIReq.Stream {var ok boolflusher, 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 linesreturn}reader := bufio.NewReader(resp.Body)for {line, err := reader.ReadString('\n')if err != nil {33 unmodified linesrespData, _ := json.Marshal(openAIResp)fmt.Fprintf(w, "data: %s\n\n", string(respData))flusher.Flush()}}}20 unmodified linesrespData, _ := 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