forked from transitive-bullshit/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.ts
42 lines (34 loc) · 800 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
41
42
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: false,
minimize: true
})
await api.initSession()
const prompt =
'Write a python version of bubble sort. Do not include example usage.'
const res = await oraPromise(api.sendMessage(prompt), {
text: prompt
})
console.log(res.response)
// close the browser at the end
await api.closeSession()
}
main().catch((err) => {
console.error(err)
process.exit(1)
})