mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-19 01:36:38 +08:00
fix bug: free model not record the chat history
This commit is contained in:
parent
2207830db9
commit
bcdf5e3776
@ -2,6 +2,11 @@
|
|||||||
## v4.0.9
|
## v4.0.9
|
||||||
* Bug修复:修复前端页面菜单把页面撑开,底部留白问题
|
* Bug修复:修复前端页面菜单把页面撑开,底部留白问题
|
||||||
* 功能优化:聊天页面自动根据内容调整输入框的高度
|
* 功能优化:聊天页面自动根据内容调整输入框的高度
|
||||||
|
* Bug修复:修复Dalle绘图失败退回算力的问题
|
||||||
|
* 功能优化:邀请码注册时被邀请人也可以获得赠送的算力
|
||||||
|
* 功能优化:允许设置邮件验证码的抬头
|
||||||
|
* Bug修复:修复免费模型不会记录聊天记录的bug
|
||||||
|
* Bug修复:修复聊天输入公式显示异常的Bug
|
||||||
## v4.0.8
|
## v4.0.8
|
||||||
* 功能优化:升级 mathjax 公式解析插件,修复公式因为图片访问限制而无法显示的问题
|
* 功能优化:升级 mathjax 公式解析插件,修复公式因为图片访问限制而无法显示的问题
|
||||||
* 功能优化:当数据库更新失败的时候记录错误日志
|
* 功能优化:当数据库更新失败的时候记录错误日志
|
||||||
|
@ -651,26 +651,25 @@ func (h *ChatHandler) saveChatHistory(
|
|||||||
logger.Error("failed to save reply history message: ", res.Error)
|
logger.Error("failed to save reply history message: ", res.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新用户算力
|
||||||
if session.Model.Power > 0 {
|
if session.Model.Power > 0 {
|
||||||
// 更新用户算力
|
|
||||||
h.subUserPower(userVo, session, promptToken, replyTokens)
|
h.subUserPower(userVo, session, promptToken, replyTokens)
|
||||||
|
}
|
||||||
// 保存当前会话
|
// 保存当前会话
|
||||||
var chatItem model.ChatItem
|
var chatItem model.ChatItem
|
||||||
res = h.DB.Where("chat_id = ?", session.ChatId).First(&chatItem)
|
res = h.DB.Where("chat_id = ?", session.ChatId).First(&chatItem)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
chatItem.ChatId = session.ChatId
|
chatItem.ChatId = session.ChatId
|
||||||
chatItem.UserId = session.UserId
|
chatItem.UserId = session.UserId
|
||||||
chatItem.RoleId = role.Id
|
chatItem.RoleId = role.Id
|
||||||
chatItem.ModelId = session.Model.Id
|
chatItem.ModelId = session.Model.Id
|
||||||
if utf8.RuneCountInString(prompt) > 30 {
|
if utf8.RuneCountInString(prompt) > 30 {
|
||||||
chatItem.Title = string([]rune(prompt)[:30]) + "..."
|
chatItem.Title = string([]rune(prompt)[:30]) + "..."
|
||||||
} else {
|
} else {
|
||||||
chatItem.Title = prompt
|
chatItem.Title = prompt
|
||||||
}
|
|
||||||
chatItem.Model = req.Model
|
|
||||||
h.DB.Create(&chatItem)
|
|
||||||
}
|
}
|
||||||
|
chatItem.Model = req.Model
|
||||||
|
h.DB.Create(&chatItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ func (h *ChatHandler) sendOpenAiMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if toolCall { // 调用函数完成任务
|
if toolCall { // 调用函数完成任务
|
||||||
var params map[string]interface{}
|
params := make(map[string]interface{})
|
||||||
_ = utils.JsonDecode(strings.Join(arguments, ""), ¶ms)
|
_ = utils.JsonDecode(strings.Join(arguments, ""), ¶ms)
|
||||||
logger.Debugf("函数名称: %s, 函数参数:%s", function.Name, params)
|
logger.Debugf("函数名称: %s, 函数参数:%s", function.Name, params)
|
||||||
params["user_id"] = userVo.Id
|
params["user_id"] = userVo.Id
|
||||||
|
@ -109,7 +109,6 @@ func (h *UserHandler) Register(c *gin.Context) {
|
|||||||
user := model.User{
|
user := model.User{
|
||||||
Username: data.Username,
|
Username: data.Username,
|
||||||
Password: utils.GenPassword(data.Password, salt),
|
Password: utils.GenPassword(data.Password, salt),
|
||||||
Nickname: fmt.Sprintf("极客学长@%d", utils.RandomNumber(6)),
|
|
||||||
Avatar: "/images/avatar/user.png",
|
Avatar: "/images/avatar/user.png",
|
||||||
Salt: salt,
|
Salt: salt,
|
||||||
Status: true,
|
Status: true,
|
||||||
@ -118,6 +117,16 @@ func (h *UserHandler) Register(c *gin.Context) {
|
|||||||
Power: h.App.SysConfig.InitPower,
|
Power: h.App.SysConfig.InitPower,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 被邀请人也获得赠送算力
|
||||||
|
if data.InviteCode != "" {
|
||||||
|
user.Power += h.App.SysConfig.InvitePower
|
||||||
|
}
|
||||||
|
if h.licenseService.GetLicense().Configs.DeCopy {
|
||||||
|
user.Username = fmt.Sprintf("用户@%d", utils.RandomNumber(6))
|
||||||
|
} else {
|
||||||
|
user.Nickname = fmt.Sprintf("极客学长@%d", utils.RandomNumber(6))
|
||||||
|
}
|
||||||
|
|
||||||
res = h.DB.Create(&user)
|
res = h.DB.Create(&user)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
resp.ERROR(c, "保存数据失败")
|
resp.ERROR(c, "保存数据失败")
|
||||||
|
@ -28,8 +28,8 @@ func NewSmtpService(appConfig *types.AppConfig) *SmtpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SmtpService) SendVerifyCode(to string, code int) error {
|
func (s *SmtpService) SendVerifyCode(to string, code int) error {
|
||||||
subject := "Geek-AI 注册验证码"
|
subject := fmt.Sprintf("%s 注册验证码", s.config.AppName)
|
||||||
body := fmt.Sprintf("您正在注册 Geek-AI 助手账户,注册验证码为 %d,请不要告诉他人。如非本人操作,请忽略此邮件。", code)
|
body := fmt.Sprintf("您正在注册 %s 账户,注册验证码为 %d,请不要告诉他人。如非本人操作,请忽略此邮件。", s.config.AppName, code)
|
||||||
|
|
||||||
auth := smtp.PlainAuth("", s.config.From, s.config.Password, s.config.Host)
|
auth := smtp.PlainAuth("", s.config.From, s.config.Password, s.config.Host)
|
||||||
if s.config.UseTls {
|
if s.config.UseTls {
|
||||||
|
@ -221,7 +221,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, watch} from "vue"
|
import {nextTick, onUnmounted, ref, watch} from "vue"
|
||||||
import {httpGet, httpPost} from "@/utils/http";
|
import {httpGet, httpPost} from "@/utils/http";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
import {setUserToken} from "@/store/session";
|
import {setUserToken} from "@/store/session";
|
||||||
@ -339,7 +339,8 @@ const submitRegister = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const close = function () {
|
const close = function () {
|
||||||
emits('hide', false);
|
emits('hide', false)
|
||||||
|
login.value = true
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -5,9 +5,8 @@
|
|||||||
<h2>会员推广计划</h2>
|
<h2>会员推广计划</h2>
|
||||||
<div class="share-box">
|
<div class="share-box">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
我们非常欢迎您把此应用分享给您身边的朋友,分享成功注册后您将获得 <strong>{{ inviteChatCalls }}</strong>
|
我们非常欢迎您把此应用分享给您身边的朋友,分享成功注册后您和被邀请人都将获得 <strong>{{ invitePower }}</strong>
|
||||||
次对话额度以及
|
算力额度作为奖励。
|
||||||
<strong>{{ inviteImgCalls }}</strong> 次AI绘画额度作为奖励。
|
|
||||||
你可以保存下面的二维码或者直接复制分享您的专属推广链接发送给微信好友。
|
你可以保存下面的二维码或者直接复制分享您的专属推广链接发送给微信好友。
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ import {useSharedStore} from "@/store/sharedata";
|
|||||||
|
|
||||||
const inviteURL = ref("")
|
const inviteURL = ref("")
|
||||||
const qrImg = ref("/images/wx.png")
|
const qrImg = ref("/images/wx.png")
|
||||||
const inviteChatCalls = ref(0)
|
const invitePower = ref(0)
|
||||||
const inviteImgCalls = ref(0)
|
const inviteImgCalls = ref(0)
|
||||||
const hits = ref(0)
|
const hits = ref(0)
|
||||||
const regNum = ref(0)
|
const regNum = ref(0)
|
||||||
@ -144,8 +143,7 @@ const initData = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
httpGet("/api/config/get?key=system").then(res => {
|
httpGet("/api/config/get?key=system").then(res => {
|
||||||
inviteChatCalls.value = res.data["invite_chat_calls"]
|
invitePower.value = res.data["invite_power"]
|
||||||
inviteImgCalls.value = res.data["invite_img_calls"]
|
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error("获取系统配置失败:" + e.message)
|
ElMessage.error("获取系统配置失败:" + e.message)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user