jimmyyem пре 5 месеци
родитељ
комит
b8f975d02d

+ 6 - 2
internal/logic/chatrecords/submit_api_chat_logic.go

@@ -192,7 +192,7 @@ func fastgptSendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiB
 			// 拼接回答
 			answer = answer + jsonData.Answer
 
-			_, err = fmt.Fprintln(w, "data: "+string(lineData)+"\n")
+			_, err = fmt.Fprintf(w, "%s", "data: "+string(lineData)+"\r\n")
 			fmt.Printf("response=%v\n", string(lineData))
 			if err != nil {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
@@ -203,6 +203,8 @@ func fastgptSendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiB
 
 			if finish {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
+				_, _ = fmt.Fprintf(w, "%s", "0\r\n")
+				flusher.Flush()
 				break
 			}
 		}
@@ -302,7 +304,7 @@ func difySendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiBase
 			// 拼接回答
 			answer = answer + jsonData.Answer
 
-			_, err = fmt.Fprintln(w, "data: "+string(lineData)+"\n")
+			_, err = fmt.Fprintf(w, "%s", "data: "+string(lineData)+"\r\n")
 			fmt.Printf("response=%v\n", string(lineData))
 			if err != nil {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
@@ -313,6 +315,8 @@ func difySendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiBase
 
 			if finish {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
+				_, _ = fmt.Fprintf(w, "%s", "0\r\n")
+				flusher.Flush()
 				break
 			}
 		}

+ 2 - 4
internal/logic/wxcard/get_api_wx_card_qrcode_logic.go

@@ -50,8 +50,6 @@ func (l *GetApiWxCardQrcodeLogic) GetApiWxCardQrcode(req *types.QrcodeReq, w htt
 	imageContent, _ := io.ReadAll(resp.Body)
 	w.Header().Set("Content-Type", "image/png")
 	w.Header().Set("Content-Length", strconv.Itoa(len(imageContent)))
-
-	_, _ = fmt.Fprintln(w, imageContent)
-
-	//fmt.Printf("imageContent=%v, contentLength=%d\n", imageContent, resp.ContentLength)
+	//_, _ = fmt.Fprintf(w, "%x", imageContent)
+	_, _ = w.Write(imageContent)
 }