2022-12-05 05:13:36 +00:00
|
|
|
import dotenv from 'dotenv-safe'
|
2022-12-02 23:43:59 +00:00
|
|
|
|
|
|
|
import { ChatGPTAPI } from './chatgpt-api'
|
|
|
|
|
2022-12-05 05:13:36 +00:00
|
|
|
dotenv.config()
|
|
|
|
|
2022-12-02 23:43:59 +00:00
|
|
|
/**
|
|
|
|
* Example CLI for testing functionality.
|
|
|
|
*/
|
|
|
|
async function main() {
|
2022-12-05 05:13:36 +00:00
|
|
|
const api = new ChatGPTAPI({ sessionToken: process.env.SESSION_TOKEN })
|
|
|
|
await api.ensureAuth()
|
2022-12-02 23:43:59 +00:00
|
|
|
|
|
|
|
const response = await api.sendMessage(
|
|
|
|
'Write a python version of bubble sort. Do not include example usage.'
|
|
|
|
)
|
2022-12-03 00:09:45 +00:00
|
|
|
|
2022-12-05 07:31:27 +00:00
|
|
|
return response
|
2022-12-02 23:43:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-05 05:13:36 +00:00
|
|
|
main()
|
|
|
|
.then((res) => {
|
|
|
|
console.log(res)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|