fix: 伪人错误记录历史的问题

This commit is contained in:
ikechan8370 2025-03-25 20:31:27 +08:00
parent eb71222ed8
commit 089f6b6316
3 changed files with 10 additions and 0 deletions

View file

@ -22,6 +22,9 @@ export class bym extends plugin {
}
async bym (e) {
if (!Chaite.getInstance()) {
return false
}
if (!ChatGPTConfig.bym.enable) {
return false
}
@ -82,6 +85,7 @@ export class bym extends plugin {
// sendMessageOption.disableHistoryRead = true
// sendMessageOption.disableHistorySave = true
sendMessageOption.conversationId = 'bym' + e.user_id + Date.now()
sendMessageOption.parentMessageId = undefined
// 设置多轮调用回掉
sendMessageOption.onMessageWithToolCall = async content => {
const { msgs, forward } = await toYunzai(e, [content])

View file

@ -27,6 +27,9 @@ export class Chat extends plugin {
}
async chat (e) {
if (!Chaite.getInstance()) {
return false
}
let state = await Chaite.getInstance().getUserStateStorage().getItem(e.sender.user_id + '')
if (!state) {
state = new YunzaiUserState(e.sender.user_id, e.sender.nickname, e.sender.card)
@ -61,6 +64,8 @@ export class Chat extends plugin {
toggleMode: Config.basic.toggleMode,
togglePrefix: Config.basic.togglePrefix
})
sendMessageOptions.conversationId = state?.current?.conversationId
sendMessageOptions.parentMessageId = state?.current?.messageId || state?.conversations.find(c => c.id === sendMessageOptions.conversationId)?.lastMessageId
if (Config.llm.enableGroupContext && e.isGroup) {
const contextPrompt = await getGroupContextPrompt(e, Config.llm.groupContextLength)
sendMessageOptions.systemOverride = sendMessageOptions.systemOverride ? sendMessageOptions.systemOverride + '\n' + contextPrompt : (preset.sendMessageOption.systemOverride + contextPrompt)