mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 对话id
This commit is contained in:
parent
d9b5d77d46
commit
2401c5aed5
2 changed files with 5 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ import { Chaite, SendMessageOption } from 'chaite'
|
|||
import { getPreset, intoUserMessage, toYunzai } from '../utils/message.js'
|
||||
import { YunzaiUserState } from '../models/chaite/user_state_storage.js'
|
||||
import { getGroupContextPrompt, getGroupHistory } from '../utils/group.js'
|
||||
import * as crypto from 'node:crypto'
|
||||
|
||||
export class Chat extends plugin {
|
||||
constructor () {
|
||||
|
|
@ -31,6 +32,9 @@ export class Chat extends plugin {
|
|||
state = new YunzaiUserState(e.sender.user_id, e.sender.nickname, e.sender.card)
|
||||
await Chaite.getInstance().getUserStateStorage().setItem(e.sender.user_id + '', state)
|
||||
}
|
||||
if (!state.current.conversationId) {
|
||||
state.current.conversationId = crypto.randomUUID()
|
||||
}
|
||||
const preset = await getPreset(e, state?.settings.preset || Config.llm.defaultChatPresetId, Config.basic.toggleMode, Config.basic.togglePrefix)
|
||||
if (!preset) {
|
||||
logger.debug('不满足对话触发条件或未找到预设,不进入对话')
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export class ChatGPTManagement extends plugin {
|
|||
for (const userState of userStates) {
|
||||
if (userState.current.conversationId && userState.current.messageId) {
|
||||
num++
|
||||
userState.current.conversationId = ''
|
||||
userState.current.conversationId = crypto.randomUUID()
|
||||
userState.current.messageId = ''
|
||||
await Chaite.getInstance().getUserStateStorage().setItem(userState.userId + '', userState)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue