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