mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
Use chatgpt-api (#106)
* feat: use the latest api from chatgpt-api * feat: use the latest api from chatgpt-api
This commit is contained in:
parent
09e8909b51
commit
bdafec9a21
3 changed files with 174 additions and 23 deletions
|
|
@ -0,0 +1,17 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue