forked from transitive-bullshit/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.ts
More file actions
33 lines (27 loc) · 600 Bytes
/
demo.ts
File metadata and controls
33 lines (27 loc) · 600 Bytes
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
import dotenv from 'dotenv-safe'
import { oraPromise } from 'ora'
import { ChatGPTAPI } from '../src'
dotenv.config()
/**
* Demo CLI for testing basic functionality.
*
* ```
* npx tsx demos/demo.ts
* ```
*/
async function main() {
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
debug: false
})
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.text)
}
main().catch((err) => {
console.error(err)
process.exit(1)
})