mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
17 lines
478 B
JavaScript
17 lines
478 B
JavaScript
import { remark } from 'remark'
|
|
import stripMarkdown from 'strip-markdown'
|
|
export function markdownToText (markdown) {
|
|
return remark()
|
|
.use(stripMarkdown)
|
|
.processSync(markdown ?? '')
|
|
.toString()
|
|
}
|
|
|
|
export async function upsertMessage (message) {
|
|
await redis.set(`CHATGPT:MESSAGE:${message.id}`, JSON.stringify(message))
|
|
}
|
|
|
|
export async function getMessageById (id) {
|
|
let messageStr = await redis.get(`CHATGPT:MESSAGE:${id}`)
|
|
return JSON.parse(messageStr)
|
|
}
|