mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
add charge link for insufficient of power
This commit is contained in:
parent
3699f024f1
commit
3ab29da8f0
@ -35,10 +35,6 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ErrorMsg = "抱歉,AI 助手开小差了,请稍后再试。"
|
|
||||||
|
|
||||||
var ErrImg = ""
|
|
||||||
|
|
||||||
var logger = logger2.GetLogger()
|
var logger = logger2.GetLogger()
|
||||||
|
|
||||||
type ChatHandler struct {
|
type ChatHandler struct {
|
||||||
@ -57,13 +53,6 @@ func NewChatHandler(app *core.AppServer, db *gorm.DB, redis *redis.Client, manag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ChatHandler) Init() {
|
|
||||||
// 如果后台有上传微信客服微信二维码,则覆盖
|
|
||||||
if h.App.SysConfig.WechatCardURL != "" {
|
|
||||||
ErrImg = fmt.Sprintf("", h.App.SysConfig.WechatCardURL)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChatHandle 处理聊天 WebSocket 请求
|
// ChatHandle 处理聊天 WebSocket 请求
|
||||||
func (h *ChatHandler) ChatHandle(c *gin.Context) {
|
func (h *ChatHandler) ChatHandle(c *gin.Context) {
|
||||||
ws, err := (&websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }}).Upgrade(c.Writer, c.Request, nil)
|
ws, err := (&websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }}).Upgrade(c.Writer, c.Request, nil)
|
||||||
@ -136,8 +125,6 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
|
|||||||
Platform: types.Platform(chatModel.Platform)}
|
Platform: types.Platform(chatModel.Platform)}
|
||||||
logger.Infof("New websocket connected, IP: %s, Username: %s", c.ClientIP(), session.Username)
|
logger.Infof("New websocket connected, IP: %s, Username: %s", c.ClientIP(), session.Username)
|
||||||
|
|
||||||
h.Init()
|
|
||||||
|
|
||||||
// 保存会话连接
|
// 保存会话连接
|
||||||
h.App.ChatClients.Put(sessionId, client)
|
h.App.ChatClients.Put(sessionId, client)
|
||||||
go func() {
|
go func() {
|
||||||
@ -212,7 +199,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userVo.Power < session.Model.Power {
|
if userVo.Power < session.Model.Power {
|
||||||
return fmt.Errorf("您当前剩余算力(%d)已不足以支付当前模型的单次对话需要消耗的算力(%d)!", userVo.Power, session.Model.Power)
|
return fmt.Errorf("您当前剩余算力 %d 已不足以支付当前模型的单次对话需要消耗的算力 %d,[立即购买](/member)。", userVo.Power, session.Model.Power)
|
||||||
}
|
}
|
||||||
|
|
||||||
if userVo.ExpiredTime > 0 && userVo.ExpiredTime <= time.Now().Unix() {
|
if userVo.ExpiredTime > 0 && userVo.ExpiredTime <= time.Now().Unix() {
|
||||||
|
@ -10,59 +10,67 @@
|
|||||||
<div class="bar" v-if="createdAt !== ''">
|
<div class="bar" v-if="createdAt !== ''">
|
||||||
<span class="bar-item"><el-icon><Clock/></el-icon> {{ createdAt }}</span>
|
<span class="bar-item"><el-icon><Clock/></el-icon> {{ createdAt }}</span>
|
||||||
<span class="bar-item">Tokens: {{ tokens }}</span>
|
<span class="bar-item">Tokens: {{ tokens }}</span>
|
||||||
<el-tooltip
|
<span class="bar-item">
|
||||||
class="box-item"
|
<el-tooltip
|
||||||
effect="dark"
|
class="box-item"
|
||||||
content="复制回答"
|
effect="dark"
|
||||||
placement="bottom"
|
content="复制回答"
|
||||||
>
|
placement="bottom"
|
||||||
<el-button type="info" class="copy-reply" :data-clipboard-text="orgContent">
|
>
|
||||||
<el-icon>
|
<el-icon class="copy-reply" :data-clipboard-text="orgContent">
|
||||||
<DocumentCopy/>
|
<DocumentCopy/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
</span>
|
||||||
|
<span class="bar-item">
|
||||||
|
<el-dropdown trigger="click">
|
||||||
|
<span class="el-dropdown-link">
|
||||||
|
<el-icon><More/></el-icon>
|
||||||
|
</span>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item :icon="Headset" @click="synthesis(orgContent)">生成语音</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import {defineComponent} from "vue"
|
import {Clock, DocumentCopy, Headset, More} from "@element-plus/icons-vue";
|
||||||
import {Clock, DocumentCopy, Position} from "@element-plus/icons-vue";
|
import {ElMessage} from "element-plus";
|
||||||
|
// eslint-disable-next-line no-undef,no-unused-vars
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'ChatReply',
|
content: {
|
||||||
components: {Position, Clock, DocumentCopy},
|
type: String,
|
||||||
props: {
|
default: '',
|
||||||
content: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
orgContent: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
tokens: {
|
|
||||||
type: Number,
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
type: String,
|
|
||||||
default: 'images/gpt-icon.png',
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
data() {
|
orgContent: {
|
||||||
return {
|
type: String,
|
||||||
finalTokens: this.tokens
|
default: '',
|
||||||
}
|
},
|
||||||
|
createdAt: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
tokens: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: 'images/gpt-icon.png',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const synthesis = (text) => {
|
||||||
|
console.log(text)
|
||||||
|
ElMessage.info("语音合成功能暂不可用")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus">
|
<style lang="stylus">
|
||||||
@ -222,6 +230,7 @@ export default defineComponent({
|
|||||||
.el-icon {
|
.el-icon {
|
||||||
position relative
|
position relative
|
||||||
top 2px;
|
top 2px;
|
||||||
|
cursor pointer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user