opt: add tip message when no available key

This commit is contained in:
RockYang 2023-07-06 10:34:01 +08:00
parent 5037df744f
commit a868a8a8b7
2 changed files with 6 additions and 2 deletions

View File

@ -197,6 +197,10 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession
if strings.Contains(err.Error(), "context canceled") {
logger.Info("用户取消了请求:", prompt)
return nil
} else if strings.Contains(err.Error(), "no available key") {
replyMessage(ws, "抱歉😔😔😔,系统已经没有可用的 API KEY🔑您可以导入自己的 API KEY🔑 继续使用!🙏🙏🙏")
replyMessage(ws, "![](/images/wx.png)")
return nil
} else {
logger.Error(err)
}
@ -414,7 +418,7 @@ func (h *ChatHandler) doRequest(ctx context.Context, user vo.User, apiKey *strin
var key model.ApiKey
res := h.db.Where("user_id = ?", 0).Order("last_used_at ASC").First(&key)
if res.Error != nil {
return nil, errors.New("no available key, please import key")
return nil, errors.New("no available key")
}
*apiKey = key.Value
// 更新 API KEY 的最后使用时间

View File

@ -31,7 +31,7 @@ const sendMsg = () => {
httpGet('/api/verify/token').then(res => {
httpPost('/api/verify/sms', {token: res.data, mobile: props.mobile}).then(() => {
ElMessage.success('短信发送成功')
let time = 10
let time = 120
btnText.value = time
const handler = setInterval(() => {
time = time - 1