2
0

🧐 Add inspectChatSession script

This commit is contained in:
Baptiste Arnaud
2024-01-25 08:43:55 +01:00
parent 7e9c67a47c
commit 53e778e0bb
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,35 @@
import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const inspectChatSession = async () => {
await promptAndSetEnvironment('production')
const id = await p.text({
message: 'Session ID?',
})
if (!id || typeof id !== 'string') {
console.log('No ID provided')
return
}
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
const chatSession = await prisma.chatSession.findFirst({
where: {
id,
},
})
if (!chatSession) {
console.log('Session not found')
return
}
console.log(JSON.stringify(chatSession, null, 2))
}
inspectChatSession()