mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +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 { getPreset, intoUserMessage, toYunzai } from '../utils/message.js'
|
||||||
import { YunzaiUserState } from '../models/chaite/user_state_storage.js'
|
import { YunzaiUserState } from '../models/chaite/user_state_storage.js'
|
||||||
import { getGroupContextPrompt, getGroupHistory } from '../utils/group.js'
|
import { getGroupContextPrompt, getGroupHistory } from '../utils/group.js'
|
||||||
|
import * as crypto from 'node:crypto'
|
||||||
|
|
||||||
export class Chat extends plugin {
|
export class Chat extends plugin {
|
||||||
constructor () {
|
constructor () {
|
||||||
|
|
@ -31,6 +32,9 @@ export class Chat extends plugin {
|
||||||
state = new YunzaiUserState(e.sender.user_id, e.sender.nickname, e.sender.card)
|
state = new YunzaiUserState(e.sender.user_id, e.sender.nickname, e.sender.card)
|
||||||
await Chaite.getInstance().getUserStateStorage().setItem(e.sender.user_id + '', state)
|
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)
|
const preset = await getPreset(e, state?.settings.preset || Config.llm.defaultChatPresetId, Config.basic.toggleMode, Config.basic.togglePrefix)
|
||||||
if (!preset) {
|
if (!preset) {
|
||||||
logger.debug('不满足对话触发条件或未找到预设,不进入对话')
|
logger.debug('不满足对话触发条件或未找到预设,不进入对话')
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ export class ChatGPTManagement extends plugin {
|
||||||
for (const userState of userStates) {
|
for (const userState of userStates) {
|
||||||
if (userState.current.conversationId && userState.current.messageId) {
|
if (userState.current.conversationId && userState.current.messageId) {
|
||||||
num++
|
num++
|
||||||
userState.current.conversationId = ''
|
userState.current.conversationId = crypto.randomUUID()
|
||||||
userState.current.messageId = ''
|
userState.current.messageId = ''
|
||||||
await Chaite.getInstance().getUserStateStorage().setItem(userState.userId + '', userState)
|
await Chaite.getInstance().getUserStateStorage().setItem(userState.userId + '', userState)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue