forked from transitive-bullshit/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.ts
40 lines (32 loc) · 766 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import dotenv from 'dotenv-safe'
import { oraPromise } from 'ora'
import { ChatGPTAPIBrowser } from '../src'
dotenv.config()
/**
* Demo CLI for testing basic functionality.
*
* ```
* npx tsx demos/demo.ts
* ```
*/
async function main() {
const email = process.env.OPENAI_EMAIL
const password = process.env.OPENAI_PASSWORD
const api = new ChatGPTAPIBrowser({ email, password, debug: true })
await api.init()
const prompt =
'Write a python version of bubble sort. Do not include example usage.'
const response = await oraPromise(api.sendMessage(prompt), {
text: prompt
})
await api.close()
return response
}
main()
.then((res) => {
console.log(res)
})
.catch((err) => {
console.error(err)
process.exit(1)
})