Skip to content

Commit

Permalink
Merge branch 'main' of github.com:yangjian102621/chatgpt-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjian102621 committed Jul 4, 2023
2 parents 2926717 + adf6916 commit 22efe81
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 19 deletions.
4 changes: 4 additions & 0 deletions api/go/handler/chat_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

// 保存当前会话
Expand Down
2 changes: 1 addition & 1 deletion api/go/handler/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ docker build -t chatgpt-plus-go:$version -f dockerfile-api-go ../
# build docker image for chatgpt-plus-vue
docker rmi -f registry.cn-hangzhou.aliyuncs.com/geekmaster/chatgpt-plus-vue:$version
docker rmi -f chatgpt-plus-vue:$version
docker build -t chatgpt-plus-vue:$version -f dockerfile-vue ../
docker build --platform linux/amd64 -t chatgpt-plus-vue:$version -f dockerfile-vue ../

# add tag for aliyum docker registry
goImageId=`docker images |grep chatgpt-plus-go |grep $version |awk '{print $3}'`
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:
# 后端 API 程序
chatgpt-plus-go:
image: registry.cn-hangzhou.aliyuncs.com/geekmaster/chatgpt-plus-go:v3.0.2
image: registry.cn-hangzhou.aliyuncs.com/geekmaster/chatgpt-plus-go:v3.0.4
# image: chatgpt-plus-go:v3.0.2
container_name: chatgpt-plus-go
restart: always
Expand All @@ -17,7 +17,7 @@ services:

# 前端应用
chatgpt-vue:
image: registry.cn-hangzhou.aliyuncs.com/geekmaster/chatgpt-plus-vue:v3.0.2
image: registry.cn-hangzhou.aliyuncs.com/geekmaster/chatgpt-plus-vue:v3.0.4
# image: chatgpt-plus-vue:v3.0.2
container_name: chatgpt-plus-vue
restart: always
Expand Down
3 changes: 0 additions & 3 deletions docker/dockerfile-api-go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ COPY ./api/go/bin/chatgpt-v3-amd64-linux /var/www/app

EXPOSE 5678

RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl

# 容器启动时执行的命令
CMD ["./chatgpt-v3-amd64-linux"]
11 changes: 2 additions & 9 deletions web/src/components/ConfigDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
v-model="showDialog"
:close-on-click-modal="false"
:before-close="close"
:top="top"
:top="50+'px'"
title="用户设置"
>
<div class="user-info" id="user-info">
Expand Down Expand Up @@ -53,7 +53,7 @@
<el-form-item label="剩余调用次数">
<el-tag>{{ form['calls'] }}</el-tag>
</el-form-item>
<el-form-item label="剩余 Tokens">
<el-form-item label="消耗 Tokens">
<el-tag type="info">{{ form['tokens'] }}</el-tag>
</el-form-item>
<el-form-item label="API KEY">
Expand Down Expand Up @@ -100,13 +100,6 @@ const form = ref({
tokens: 0,
chat_configs: {}
})
const top = computed(() => {
if (window.innerHeight < 1024) {
return '5vh';
} else {
return '15vh';
}
})
onMounted(() => {
// 获取最新用户信息
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/mobile/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</template>
</van-field>

<van-field label="剩余 Tokens">
<van-field label="消耗 Tokens">
<template #input>
<van-tag type="primary">{{ form.tokens }}</van-tag>
</template>
Expand Down
3 changes: 1 addition & 2 deletions web/src/views/mobile/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
name="API KEY"
label="API KEY"
placeholder="配置自己的 api key"
:rules="[{ required: true, message: '请填写 API KEY' }]"
/>
</van-cell-group>
<div style="margin: 16px;">
Expand Down Expand Up @@ -126,4 +125,4 @@ const save = () => {
padding-top 60px
}
}
</style>
</style>

0 comments on commit 22efe81

Please sign in to comment.