From 3194becdad2f45a4a185eeae91b520c256838a48 Mon Sep 17 00:00:00 2001 From: ly307787186 <475067517@qq.com> Date: Fri, 30 Jun 2023 13:20:30 +0800 Subject: [PATCH 1/3] Update Setting.vue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关掉aip-key 必需的验证 --- web/src/views/mobile/Setting.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/src/views/mobile/Setting.vue b/web/src/views/mobile/Setting.vue index 155cd2fd..12a567d7 100644 --- a/web/src/views/mobile/Setting.vue +++ b/web/src/views/mobile/Setting.vue @@ -45,7 +45,6 @@ name="API KEY" label="API KEY" placeholder="配置自己的 api key" - :rules="[{ required: true, message: '请填写 API KEY' }]" />
@@ -126,4 +125,4 @@ const save = () => { padding-top 60px } } - \ No newline at end of file + From 31c14bf7483800da31a50c4da6f5e97cceb2494b Mon Sep 17 00:00:00 2001 From: RockYang Date: Sat, 1 Jul 2023 23:29:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=20token=20=E6=B6=88=E8=80=97=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/go/handler/chat_handler.go | 4 ++++ api/go/handler/user_handler.go | 2 +- web/src/components/ConfigDialog.vue | 11 ++--------- web/src/views/mobile/Profile.vue | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/api/go/handler/chat_handler.go b/api/go/handler/chat_handler.go index 177e5296..3707d80c 100644 --- a/api/go/handler/chat_handler.go +++ b/api/go/handler/chat_handler.go @@ -319,6 +319,10 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession if res.Error != nil { logger.Error("failed to save reply history message: ", res.Error) } + + // 统计用户 token 数量 + h.db.Model(&user).UpdateColumn("tokens", gorm.Expr("tokens + ?", + historyUserMsg.Tokens+historyReplyMsg.Tokens)) } // 保存当前会话 diff --git a/api/go/handler/user_handler.go b/api/go/handler/user_handler.go index c329957c..8a2e662a 100644 --- a/api/go/handler/user_handler.go +++ b/api/go/handler/user_handler.go @@ -240,7 +240,7 @@ type userProfile struct { Avatar string `json:"avatar"` ChatConfig types.ChatConfig `json:"chat_config"` Calls int `json:"calls"` - Tokens int `json:"tokens"` + Tokens int64 `json:"tokens"` } func (h *UserHandler) Profile(c *gin.Context) { diff --git a/web/src/components/ConfigDialog.vue b/web/src/components/ConfigDialog.vue index 10931e10..8de7c8e3 100644 --- a/web/src/components/ConfigDialog.vue +++ b/web/src/components/ConfigDialog.vue @@ -3,7 +3,7 @@ v-model="showDialog" :close-on-click-modal="false" :before-close="close" - :top="top" + :top="50+'px'" title="用户设置" >