From 2401c5aed532ad0e656af2ecfa4b2e75f8a201eb Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Fri, 21 Mar 2025 12:50:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E8=AF=9Did?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 4 ++++ apps/management.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/chat.js b/apps/chat.js index 9ace857..d5e76ed 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -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('不满足对话触发条件或未找到预设,不进入对话') diff --git a/apps/management.js b/apps/management.js index 813c19e..f2f5184 100644 --- a/apps/management.js +++ b/apps/management.js @@ -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) }