Refactor to use ai/rsc (#253)
This commit is contained in:
parent
69ca8fcc22
commit
e85ba803dd
66 changed files with 2799 additions and 740 deletions
|
|
@ -127,3 +127,30 @@ export async function shareChat(id: string) {
|
|||
|
||||
return payload
|
||||
}
|
||||
|
||||
export async function saveChat(chat: Chat) {
|
||||
const session = await auth()
|
||||
|
||||
if (session && session.user) {
|
||||
const pipeline = kv.pipeline()
|
||||
pipeline.hmset(`chat:${chat.id}`, chat)
|
||||
pipeline.zadd(`user:chat:${chat.userId}`, {
|
||||
score: Date.now(),
|
||||
member: `chat:${chat.id}`
|
||||
})
|
||||
await pipeline.exec()
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export async function refreshHistory(path: string) {
|
||||
redirect(path)
|
||||
}
|
||||
|
||||
export async function getMissingKeys() {
|
||||
const keysRequired = ['OPENAI_API_KEY']
|
||||
return keysRequired
|
||||
.map(key => (process.env[key] ? '' : key))
|
||||
.filter(key => key !== '')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue