Bläddra i källkod

fix:edit submit_chat API

jimmyyem 5 månader sedan
förälder
incheckning
2c9c6b45af
1 ändrade filer med 4 tillägg och 9 borttagningar
  1. 4 9
      internal/logic/chatrecords/submit_api_chat_logic.go

+ 4 - 9
internal/logic/chatrecords/submit_api_chat_logic.go

@@ -124,7 +124,6 @@ func fastgptSendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiB
 
 	// 建立HTTP請求
 	url := apiBase + fastgpt.GetChatUrl()
-	fmt.Printf("url=%v token=%v\n", url, apiKey)
 	request, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
 	if err != nil {
 		fmt.Printf("Error creating request:%v", err)
@@ -160,7 +159,7 @@ func fastgptSendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiB
 	for {
 		line, err := reader.ReadString('\n')
 		line = strings.Trim(line, " \n")
-		fmt.Printf("line = %v\n", line)
+		//fmt.Printf("line = %v\n", line)
 
 		if err == io.EOF {
 			break
@@ -193,7 +192,7 @@ func fastgptSendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiB
 			answer = answer + jsonData.Answer
 
 			_, err = fmt.Fprintf(w, "%s", "data: "+string(lineData)+"\r\n")
-			fmt.Printf("response=%v\n", string(lineData))
+			//fmt.Printf("response=%v\n", string(lineData))
 			if err != nil {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
 				fmt.Printf("Error writing to client:%v \n", err)
@@ -203,8 +202,6 @@ 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
 			}
 		}
@@ -266,7 +263,7 @@ func difySendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiBase
 	for {
 		line, err := reader.ReadString('\n')
 		line = strings.Trim(line, " \n")
-		fmt.Printf("line = %v\n", line)
+		//fmt.Printf("line = %v\n", line)
 
 		if err == io.EOF {
 			break
@@ -305,7 +302,7 @@ func difySendChat(l *SubmitApiChatLogic, w http.ResponseWriter, content, apiBase
 			answer = answer + jsonData.Answer
 
 			_, err = fmt.Fprintf(w, "%s", "data: "+string(lineData)+"\r\n")
-			fmt.Printf("response=%v\n", string(lineData))
+			//fmt.Printf("response=%v\n", string(lineData))
 			if err != nil {
 				logAnswer(l, userId, sessionId, botId, botType, answer)
 				fmt.Printf("Error writing to client:%v \n", err)
@@ -315,8 +312,6 @@ 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
 			}
 		}