handler chat error in the chat entry func

This commit is contained in:
RockYang
2024-05-15 15:30:34 +08:00
parent 3ab29da8f0
commit 36c27d6092
7 changed files with 14 additions and 23 deletions

View File

@@ -58,9 +58,9 @@ func (h *ChatHandler) sendBaiduMessage(
response, err := h.doRequest(ctx, req, session, &apiKey)
logger.Info("HTTP请求完成耗时", time.Now().Sub(start))
if err != nil {
logger.Error(err)
if strings.Contains(err.Error(), "context canceled") {
logger.Info("用户取消了请求:", prompt)
return nil
return fmt.Errorf("用户取消了请求:%s", prompt)
} else if strings.Contains(err.Error(), "no available key") {
return errors.New("抱歉😔😔😔,系统已经没有可用的 API KEY请联系管理员")
}