feat: init v3

This commit is contained in:
ikechan8370 2025-03-05 23:56:41 +08:00
parent d6cb085c40
commit 531986b2dc
284 changed files with 618 additions and 405179 deletions

View file

@ -0,0 +1,53 @@
import ChatGPTStorage from '../storage.js'
/**
* @returns {import('chaite').ChatPresetsStorage}
*/
export async function createChatPresetsStorage () {
return new LowDBChatPresetsStorage(ChatGPTStorage)
}
class LowDBChatPresetsStorage {
/**
*
* @param { LowDBStorage } storage
*/
constructor (storage) {
this.storage = storage
/**
* 集合
* @type {LowDBCollection}
*/
this.collection = this.storage.collection('chat_presets')
}
/**
*
* @param {import('chaite').ChatPreset} preset
* @returns {Promise<void>}
*/
async savePreset (preset) {
await this.collection.insert(preset)
}
/**
*
* @param { string } name
* @returns {Promise<import('chaite').ChatPreset | null>}
*/
async getPreset (name) {
return this.collection.findOne({ name })
}
/**
*
* @returns {Promise<import('chaite').ChatPreset[]>}
*/
async getAllPresets () {
return this.collection.findAll()
}
async deletePreset (name) {
await this.collection.delete({ name })
}
}