fix: 对话id

This commit is contained in:
ikechan8370 2025-03-21 12:50:11 +08:00
parent d9b5d77d46
commit 2401c5aed5
2 changed files with 5 additions and 1 deletions

View file

@ -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('不满足对话触发条件或未找到预设,不进入对话')