mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 调试设定和伪人
This commit is contained in:
parent
efb5a8f174
commit
3c77da5373
11 changed files with 293 additions and 34 deletions
|
|
@ -37,13 +37,13 @@ export class LowDBHistoryManager extends AbstractHistoryManager {
|
|||
const message = await this.collection.findOne({ id: currentId })
|
||||
if (!message) break
|
||||
messages.unshift(message)
|
||||
currentId = message.parentMessageId
|
||||
currentId = message.parentId
|
||||
}
|
||||
return messages
|
||||
} else if (conversationId) {
|
||||
return this.collection.find({ conversationId })
|
||||
}
|
||||
return this.collection.findAll()
|
||||
return []
|
||||
}
|
||||
|
||||
async deleteConversation (conversationId) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,22 @@
|
|||
import { ChaiteStorage } from 'chaite'
|
||||
import * as crypto from 'node:crypto'
|
||||
|
||||
/**
|
||||
* 继承UserState
|
||||
*/
|
||||
export class YunzaiUserState {
|
||||
constructor (userId, nickname, card, conversationId = crypto.randomUUID()) {
|
||||
this.userId = userId
|
||||
this.nickname = nickname
|
||||
this.card = card
|
||||
this.conversations = []
|
||||
this.settings = {}
|
||||
this.current = {
|
||||
conversationId,
|
||||
messageId: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @extends {ChaiteStorage<import('chaite').UserState>}
|
||||
|
|
@ -35,9 +53,12 @@ export class LowDBUserStateStorage extends ChaiteStorage {
|
|||
*/
|
||||
async setItem (id, state) {
|
||||
if (id) {
|
||||
await this.collection.updateById(id, state)
|
||||
return id
|
||||
if (await this.getItem(id)) {
|
||||
await this.collection.updateById(id, state)
|
||||
return id
|
||||
}
|
||||
}
|
||||
state.id = id
|
||||
const result = await this.collection.insert(state)
|
||||
return result.id
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue